]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DHCPv6 decoder fix 316/head
authorfxlb <[email protected]>
Fri, 31 May 2013 13:25:29 +0000 (15:25 +0200)
committerfxlb <[email protected]>
Fri, 31 May 2013 13:25:29 +0000 (15:25 +0200)
- fix the tests for DH6OPT_SIP_SERVER_D, DH6OPT_DOMAIN_LIST and DH6OPT_NTP_SERVER,
- add missing ")".

print-dhcp6.c
tests/dhcpv6-domain-list.out
tests/dhcpv6-sip-server-d.out

index 52f823dfa9b4a64437795c3249efefbf6b8826e7..255f24aa1f84702c2491a56ba7411772f91ffac1 100644 (file)
@@ -608,11 +608,12 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                case DH6OPT_SIP_SERVER_D:
                case DH6OPT_DOMAIN_LIST:
                        tp = (u_char *)(dh6o + 1);
-                       while (tp < ep) {
+                       while (tp < cp + sizeof(*dh6o) + optlen) {
                                putchar(' ');
-                               if((tp = ns_nprint(tp, ep)) == NULL)
+                               if ((tp = ns_nprint(tp, cp + sizeof(*dh6o) + optlen)) == NULL)
                                        goto trunc;
                        }
+                       printf(")");
                        break;
                case DH6OPT_STATUS_CODE:
                        if (optlen < 2) {
@@ -743,11 +744,13 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                                break;
                        }
                        tp = (u_char *)(dh6o + 1);
-                       while (tp < ep - 4) {
+                       while (tp < cp + sizeof(*dh6o) + optlen - 4) {
                                subopt_code = EXTRACT_16BITS(tp);
                                tp += 2;
                                subopt_len = EXTRACT_16BITS(tp);
                                tp += 2;
+                               if (tp + subopt_len > cp + sizeof(*dh6o) + optlen)
+                                       goto trunc;
                                printf(" subopt:%d", subopt_code);
                                switch (subopt_code) {
                                case DH6OPT_NTP_SUBOPTION_SRV_ADDR:
@@ -757,17 +760,17 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                                                break;
                                        }
                                        printf(" %s", ip6addr_string(&tp[0]));
-                                       tp += subopt_len;
                                        break;
                                case DH6OPT_NTP_SUBOPTION_SRV_FQDN:
                                        putchar(' ');
-                                       ns_nprint(tp, ep);
-                                       tp += subopt_len;
+                                       if (ns_nprint(tp, tp + subopt_len) == NULL)
+                                               goto trunc;
                                        break;
                                default:
                                        printf(" ?");
                                        break;
                                }
+                               tp += subopt_len;
                        }
                        printf(")");
                        break;
index 965f091d499f307a0fe215f0c3e4f62ea03ec7fa..30b449cc7b75e150b64605fb0c9523112bf1dee2 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header UDP (17) payload length: 101) fe80::20c:29ff:fe9b:a15d.547 > fe80::20c:29ff:fe38:f368.546: [udp sum ok] dhcp6 reply (xid=aa56ce (client-ID hwaddr/time type 1 time 418384703 000c2938f368) (server-ID hwaddr/time type 1 time 418354459 000c299ba153) (DNS-search-list example.com. sales.example.com. eng.example.com.)
+IP6 (hlim 64, next-header UDP (17) payload length: 101) fe80::20c:29ff:fe9b:a15d.547 > fe80::20c:29ff:fe38:f368.546: [udp sum ok] dhcp6 reply (xid=aa56ce (client-ID hwaddr/time type 1 time 418384703 000c2938f368) (server-ID hwaddr/time type 1 time 418354459 000c299ba153) (DNS-search-list example.com. sales.example.com. eng.example.com.))
index 62f8992d019dd5ec96876b63d285404df9e77c30..4600e9f2cc995240a36f6c93de834a5e2304c3e7 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header UDP (17) payload length: 114) fe80::20c:29ff:fe9b:a15d.547 > fe80::20c:29ff:fe38:f368.546: [udp sum ok] dhcp6 reply (xid=6890d8 (client-ID hwaddr/time type 1 time 418384703 000c2938f368) (server-ID hwaddr/time type 1 time 418354459 000c299ba153) (SIP-servers-domain sip1.my-domain.net. sip2.example.com. sip3.sub.my-domain.org.)
+IP6 (hlim 64, next-header UDP (17) payload length: 114) fe80::20c:29ff:fe9b:a15d.547 > fe80::20c:29ff:fe38:f368.546: [udp sum ok] dhcp6 reply (xid=6890d8 (client-ID hwaddr/time type 1 time 418384703 000c2938f368) (server-ID hwaddr/time type 1 time 418354459 000c299ba153) (SIP-servers-domain sip1.my-domain.net. sip2.example.com. sip3.sub.my-domain.org.))