Skip to content

Commit

Permalink
dp-packet: Ensure packet base is always non-NULL.
Browse files Browse the repository at this point in the history
UB Sanitizer report:
  lib/dp-packet.h:297:39: runtime error: applying zero offset to null pointer
      #0 0x7946f5 in dp_packet_tail ./lib/dp-packet.h:297:39
      #1 0x794331 in dp_packet_tailroom ./lib/dp-packet.h:325:49
      #2 0x7942a0 in dp_packet_prealloc_tailroom lib/dp-packet.c:297:16
      #3 0xc347cf in eth_compose lib/packets.c:1061:5
      [...]

Signed-off-by: Dumitru Ceara <[email protected]>
Acked-by: Paolo Valerio <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
dceara authored and igsilya committed Feb 14, 2022
1 parent 172d8bf commit 3ffeb03
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dp-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ dp_packet_resize(struct dp_packet *b, size_t new_headroom, size_t new_tailroom)
void
dp_packet_prealloc_tailroom(struct dp_packet *b, size_t size)
{
if (size > dp_packet_tailroom(b)) {
if ((size && !dp_packet_base(b)) || (size > dp_packet_tailroom(b))) {
dp_packet_resize(b, dp_packet_headroom(b), MAX(size, 64));
}
}
Expand Down

0 comments on commit 3ffeb03

Please sign in to comment.