RT6: Add a bounds check for the PadN TLV in Segment Routing Header

Define ND_LONGJMP_FROM_TCHECK.

Add a test file.
This commit is contained in:
Francois-Xavier Le Bail 2024-11-15 13:54:35 +01:00 committed by fxlb
parent f60ddc5b3e
commit 3b2df87bc6
4 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "netdissect-stdinc.h"
#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@ -65,6 +66,7 @@ srh_tlv_print(netdissect_options *ndo, const u_char *p, u_int bytes_left)
case IPV6_SRH_TLV_PADN:
ND_ICHECKMSG_U("PadN length", tlv_len, >, 5); /* RFC 8754 */
ND_ICHECKMSG_U("remaining length", bytes_left, <, tlv_len);
ND_TCHECK_LEN(p, tlv_len);
p += tlv_len;
bytes_left -= tlv_len;
break;

View File

@ -392,6 +392,7 @@ ipv6-srh-tlv-hmac ipv6-srh-tlv-hmac.pcap ipv6-srh-tlv-hmac.out
ipv6-srh-tlv-hmac-v ipv6-srh-tlv-hmac.pcap ipv6-srh-tlv-hmac-v.out -v
ipv6-srh-tlv-pad1-padn-5 ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn-5.out
ipv6-srh-tlv-pad1-padn-5-v ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn-5-v.out -v
ipv6-srh-tlv-pad1-padn-5-trunc ipv6-srh-tlv-pad1-padn-5-trunc.pcap ipv6-srh-tlv-pad1-padn-5-trunc.out
ipv6_invalid_length ipv6_invalid_length.pcap ipv6_invalid_length.out
ipv6_invalid_length_2 ipv6_invalid_length_2.pcap ipv6_invalid_length_2.out -v
ipv6_jumbogram_invalid_length ipv6_jumbogram_invalid_length.pcap ipv6_jumbogram_invalid_length.out -v

View File

@ -0,0 +1 @@
1 2022-11-11 17:47:55.4294964993 IP6 2001:db8:1::1 > cafe:1::2: RT6 (len=3, type=4, segleft=0, last-entry=0, tag=0, [0]cafe:1::2, TLV-type=Pad1(0), TLV-type=PadN(4), TLV-len=5 [|rt6]

Binary file not shown.