Skip to content

Commit b6dde13

Browse files
committed
Fix handling of Jumbo option when it's a destination option.
Pass null pointers to ip6_opt_process() when processing destination options, and have ip6_opt_process() check for a null pointer-to-payload- length when processing a Jumbo option and, if the pointer is null, report it as not being a hop-by-hop option. This fixes an uninitialized-data fetch.
1 parent 93f3e43 commit b6dde13

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

print-ip6opts.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,19 @@ ip6_opt_process(netdissect_options *ndo, const u_char *bp, int len,
150150
ND_PRINT("(jumbo: %u - already seen) ", jumbolen);
151151
} else {
152152
found_jumbo = 1;
153-
if (*payload_len != 0) {
153+
if (payload_len == NULL) {
154+
/* Not a hop-by-hop option - not valid */
155+
if (ndo->ndo_vflag)
156+
ND_PRINT("(jumbo: %u - not a hop-by-hop option) ", jumbolen);
157+
} else if (*payload_len != 0) {
154158
/* Payload length was non-zero - not valid */
155159
if (ndo->ndo_vflag)
156160
ND_PRINT("(jumbo: %u - payload len != 0) ", jumbolen);
157161
} else {
158-
/* Payload length was zero in the IPv6 header */
162+
/*
163+
* This is a hop-by-hop option, and Payload length
164+
* was zero in the IPv6 header.
165+
*/
159166
if (jumbolen < 65536) {
160167
/* Too short */
161168
if (ndo->ndo_vflag)
@@ -235,8 +242,6 @@ dstopt_process(netdissect_options *ndo, const u_char *bp)
235242
{
236243
const struct ip6_dest *dp = (const struct ip6_dest *)bp;
237244
u_int dstoptlen = 0;
238-
int found_jumbo;
239-
uint32_t jumbolen;
240245

241246
ndo->ndo_protocol = "dstopt";
242247
ND_TCHECK_1(dp->ip6d_len);
@@ -245,12 +250,12 @@ dstopt_process(netdissect_options *ndo, const u_char *bp)
245250
ND_PRINT("DSTOPT ");
246251
if (ndo->ndo_vflag) {
247252
/*
248-
* The Jumbo Payload option is a hop-by-hop option; we print,
249-
* but don't honor, Jumbo Payload destination options.
253+
* The Jumbo Payload option is a hop-by-hop option; we don't
254+
* honor Jumbo Payload destination options, reporting them
255+
* as invalid.
250256
*/
251257
if (ip6_opt_process(ndo, (const u_char *)dp + sizeof(*dp),
252-
dstoptlen - sizeof(*dp), &found_jumbo,
253-
&jumbolen) == -1)
258+
dstoptlen - sizeof(*dp), NULL, NULL) == -1)
254259
goto trunc;
255260
}
256261

0 commit comments

Comments
 (0)