Skip to content

Commit 91977d2

Browse files
committed
QUIC: Fix a pointer overflow with 32-bit executable
When decoding an IPv6 Jumbo frame, the lenght of the payload may be huge (e.g. 201311154). This gives a huge length to udp_print() and then to quic_print() (e.g. 201311130). With 32-bit executable, addding the length to the pointer can overflow, like: print-quic.c:277:26: runtime error: pointer index expression with base 0xf42032c0 overflowed to 0x001ff65a Use ND_BYTES_AVAILABLE_AFTER() to assign the 'end' pointer. quic_print(): Remove the parameter 'len' no longer used. Add a test file. Update the output of a test accordingly (packet 10 not truncated).
1 parent f690437 commit 91977d2

File tree

7 files changed

+8
-6
lines changed

7 files changed

+8
-6
lines changed

netdissect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ extern void ptp_print(netdissect_options *, const u_char *, u_int);
724724
extern const char *q922_string(netdissect_options *, const u_char *, u_int);
725725
extern void q933_print(netdissect_options *, const u_char *, u_int);
726726
extern int quic_detect(netdissect_options *, const u_char *, const u_int);
727-
extern void quic_print(netdissect_options *, const u_char *, const u_int);
727+
extern void quic_print(netdissect_options *, const u_char *);
728728
extern void radius_print(netdissect_options *, const u_char *, u_int);
729729
extern void resp_print(netdissect_options *, const u_char *, u_int);
730730
extern void rip_print(netdissect_options *, const u_char *, u_int);

print-quic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ quic_print_packet(netdissect_options *ndo, const u_char *bp, const u_char *end)
272272
}
273273

274274
void
275-
quic_print(netdissect_options *ndo, const u_char *bp, const u_int len)
275+
quic_print(netdissect_options *ndo, const u_char *bp)
276276
{
277-
const uint8_t *end = bp + len;
277+
const uint8_t *end = bp + ND_BYTES_AVAILABLE_AFTER(bp);
278278

279279
ndo->ndo_protocol = "quic";
280280
nd_print_protocol(ndo);

print-udp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
464464
domain_print(ndo, cp, length, FALSE, FALSE);
465465
break;
466466
case PT_QUIC:
467-
quic_print(ndo, cp, length);
467+
quic_print(ndo, cp);
468468
break;
469469
}
470470
return;
@@ -674,7 +674,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
674674
someip_print(ndo, cp, length);
675675
else if (IS_SRC_OR_DST_PORT(HTTPS_PORT) &&
676676
quic_detect(ndo, cp, length))
677-
quic_print(ndo, cp, length);
677+
quic_print(ndo, cp);
678678
else if (sport == BCM_LI_PORT)
679679
bcm_li_print(ndo, cp, length);
680680
else {

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ quic_handshake quic_handshake.pcap quic_handshake.out -v
907907
quic_handshake_truncated quic_handshake_truncated.pcap quic_handshake_truncated.out -v
908908
quic_retry quic_retry.pcap quic_retry.out -v
909909
gquic gquic.pcap gquic.out -v
910+
quic_32_bit_pointer_overflow quic_32_bit_pointer_overflow.pcap quic_32_bit_pointer_overflow.out
910911

911912
# GRE keepalives, CDP over GRE
912913
various_gre various_gre.pcap various_gre.out -v
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 14:32:46.453540455 IP6 ::8:46:ee:102:202:202 > 202:200:0:fe7e:b65f:677a:82b:601: HBH truncated-ip6 - 201252743 bytes missing!0 > 443: quic, initial, vb2a10200, dcid 00000100, length 1 [|quic]
124 Bytes
Binary file not shown.

tests/quic_handshake_truncated.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
7 19:57:02.485464 IP6 (class 0x02, flowlabel 0x70e00, hlim 64, next-header UDP (17) payload length: 81) ::1.65165 > ::1.443: [bad udp cksum 0x0064 -> 0x9855!] quic, handshake, dcid beb256567ee5698c, length 56
88
8 19:57:02.485711 IP6 (class 0x02, flowlabel 0x50700, hlim 64, next-header UDP (17) payload length: 50) ::1.443 > ::1.65165: [bad udp cksum 0x0045 -> 0xca20!] quic, handshake, scid beb256567ee5698c, length 25
99
9 19:57:02.485809 IP6 (class 0x02, flowlabel 0x50700, hlim 64, next-header UDP (17) payload length: 29) ::1.443 > ::1.65165: [bad udp cksum 0x0030 -> 0x4f93!] quic, protected
10-
10 19:57:02.486075 IP6 (class 0x02, flowlabel 0x50700, hlim 64, next-header UDP (17) payload length: 250) ::1.443 > ::1.65165: quic, protected [|quic]
10+
10 19:57:02.486075 IP6 (class 0x02, flowlabel 0x50700, hlim 64, next-header UDP (17) payload length: 250) ::1.443 > ::1.65165: quic, protected
1111
11 19:57:02.486726 IP6 (class 0x02, flowlabel 0x70e00, hlim 64, next-header UDP (17) payload length: 39) ::1.65165 > ::1.443: [bad udp cksum 0x003a -> 0x38d3!] quic, protected, dcid beb256567ee5698c
1212
12 19:57:02.487067 IP6 (class 0x02, flowlabel 0x70e00, hlim 64, next-header UDP (17) payload length: 37) ::1.65165 > ::1.443: [bad udp cksum 0x0038 -> 0x3993!] quic, protected, dcid beb256567ee5698c
1313
13 19:57:02.487144 IP6 (class 0x02, flowlabel 0x70e00, hlim 64, next-header UDP (17) payload length: 37) ::1.65165 > ::1.443: [bad udp cksum 0x0038 -> 0x7ae0!] quic, protected, dcid beb256567ee5698c

0 commit comments

Comments
 (0)