Skip to content

Commit a4508ee

Browse files
committed
DHCP: Fix printing IP address pairs options
'p' is used by the options Policy Filter (21) and Static Route (33). They have a minimum length of 8 and the length MUST be a multiple of 8. Check that. Add a test file for option 33 (lengths: 8, 16, 24, 3, 0), build with scapy.
1 parent 60237c7 commit a4508ee

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

print-bootp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,14 @@ rfc1048_print(netdissect_options *ndo,
707707

708708
case 'p':
709709
/* IP address pairs */
710+
/* this option should be N x 8 bytes long */
711+
if (len < 8 || len % 8 != 0) {
712+
ND_PRINT("%s[length != N x 8 bytes]",
713+
len == 0 ? " " : "");
714+
bp += len;
715+
len = 0;
716+
break;
717+
}
710718
while (len >= 2*4) {
711719
if (!first)
712720
ND_PRINT(",");

tests/TESTLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -v
524524
dhcp-rfc4388 dhcp-rfc4388.pcap dhcp-rfc4388.out -v
525525
dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -v
526526
dhcp-mud dhcp-mud.pcap dhcp-mud.out -vv
527+
dhcp-option-33 dhcp-option-33.pcap dhcp-option-33.out -vvv
527528

528529
# VXLAN tests
529530
vxlan vxlan.pcap vxlan.out -e

tests/dhcp-option-33.out

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
1 2025-03-22 09:05:13.138257 IP (tos 0x0, ttl 64, id 1, offset 0, flags [none], proto UDP (17), length 294)
2+
192.168.1.1.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 266, xid 0x12345678, Flags [none] (0x0000)
3+
Your-IP 192.168.1.100
4+
Server-IP 192.168.1.1
5+
Client-Ethernet-Address 00:11:22:33:44:55
6+
Vendor-rfc1048 Extensions
7+
Magic Cookie 0x63825363
8+
DHCP-Message (53), length 1: Offer
9+
Server-ID (54), length 4: 192.168.1.1
10+
Lease-Time (51), length 4: 86400
11+
Static-Route (33), length 8: (10.0.0.1:10.0.0.2)
12+
END (255), length 0
13+
2 2025-03-22 09:05:13.141437 IP (tos 0x0, ttl 64, id 1, offset 0, flags [none], proto UDP (17), length 302)
14+
192.168.1.1.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 274, xid 0x12345678, Flags [none] (0x0000)
15+
Your-IP 192.168.1.100
16+
Server-IP 192.168.1.1
17+
Client-Ethernet-Address 00:11:22:33:44:55
18+
Vendor-rfc1048 Extensions
19+
Magic Cookie 0x63825363
20+
DHCP-Message (53), length 1: Offer
21+
Server-ID (54), length 4: 192.168.1.1
22+
Lease-Time (51), length 4: 86400
23+
Static-Route (33), length 16: (10.0.0.1:10.0.0.2),(10.0.0.3:10.0.0.4)
24+
END (255), length 0
25+
3 2025-03-22 09:05:13.144047 IP (tos 0x0, ttl 64, id 1, offset 0, flags [none], proto UDP (17), length 310)
26+
192.168.1.1.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 282, xid 0x12345678, Flags [none] (0x0000)
27+
Your-IP 192.168.1.100
28+
Server-IP 192.168.1.1
29+
Client-Ethernet-Address 00:11:22:33:44:55
30+
Vendor-rfc1048 Extensions
31+
Magic Cookie 0x63825363
32+
DHCP-Message (53), length 1: Offer
33+
Server-ID (54), length 4: 192.168.1.1
34+
Lease-Time (51), length 4: 86400
35+
Static-Route (33), length 24: (10.0.0.1:10.0.0.2),(10.0.0.3:10.0.0.4),(10.0.0.5:10.0.0.6)
36+
END (255), length 0
37+
4 2025-03-22 09:05:13.146056 IP (tos 0x0, ttl 64, id 1, offset 0, flags [none], proto UDP (17), length 289)
38+
192.168.1.1.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 261, xid 0x12345678, Flags [none] (0x0000)
39+
Your-IP 192.168.1.100
40+
Server-IP 192.168.1.1
41+
Client-Ethernet-Address 00:11:22:33:44:55
42+
Vendor-rfc1048 Extensions
43+
Magic Cookie 0x63825363
44+
DHCP-Message (53), length 1: Offer
45+
Server-ID (54), length 4: 192.168.1.1
46+
Lease-Time (51), length 4: 86400
47+
Static-Route (33), length 3: [length != N x 8 bytes]
48+
END (255), length 0
49+
5 2025-03-22 09:05:13.148070 IP (tos 0x0, ttl 64, id 1, offset 0, flags [none], proto UDP (17), length 286)
50+
192.168.1.1.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 258, xid 0x12345678, Flags [none] (0x0000)
51+
Your-IP 192.168.1.100
52+
Server-IP 192.168.1.1
53+
Client-Ethernet-Address 00:11:22:33:44:55
54+
Vendor-rfc1048 Extensions
55+
Magic Cookie 0x63825363
56+
DHCP-Message (53), length 1: Offer
57+
Server-ID (54), length 4: 192.168.1.1
58+
Lease-Time (51), length 4: 86400
59+
Static-Route (33), length 0 [length != N x 8 bytes]
60+
END (255), length 0

tests/dhcp-option-33.pcap

1.62 KB
Binary file not shown.

0 commit comments

Comments
 (0)