diff options
Diffstat (limited to 'net/ipv4/ip_options.c')
-rw-r--r-- | net/ipv4/ip_options.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index ec7264514a82..f4ab72e19af9 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
@@ -167,7 +167,7 @@ int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb) | |||
167 | soffset -= 4; | 167 | soffset -= 4; |
168 | if (soffset > 3) { | 168 | if (soffset > 3) { |
169 | memcpy(&faddr, &start[soffset-1], 4); | 169 | memcpy(&faddr, &start[soffset-1], 4); |
170 | for (soffset-=4, doffset=4; soffset > 3; soffset-=4, doffset+=4) | 170 | for (soffset -= 4, doffset = 4; soffset > 3; soffset -= 4, doffset += 4) |
171 | memcpy(&dptr[doffset-1], &start[soffset-1], 4); | 171 | memcpy(&dptr[doffset-1], &start[soffset-1], 4); |
172 | /* | 172 | /* |
173 | * RFC1812 requires to fix illegal source routes. | 173 | * RFC1812 requires to fix illegal source routes. |
@@ -227,7 +227,7 @@ void ip_options_fragment(struct sk_buff *skb) | |||
227 | continue; | 227 | continue; |
228 | } | 228 | } |
229 | optlen = optptr[1]; | 229 | optlen = optptr[1]; |
230 | if (optlen<2 || optlen>l) | 230 | if (optlen < 2 || optlen > l) |
231 | return; | 231 | return; |
232 | if (!IPOPT_COPIED(*optptr)) | 232 | if (!IPOPT_COPIED(*optptr)) |
233 | memset(optptr, IPOPT_NOOP, optlen); | 233 | memset(optptr, IPOPT_NOOP, optlen); |
@@ -275,27 +275,27 @@ int ip_options_compile(struct net *net, | |||
275 | 275 | ||
276 | for (l = opt->optlen; l > 0; ) { | 276 | for (l = opt->optlen; l > 0; ) { |
277 | switch (*optptr) { | 277 | switch (*optptr) { |
278 | case IPOPT_END: | 278 | case IPOPT_END: |
279 | for (optptr++, l--; l>0; optptr++, l--) { | 279 | for (optptr++, l--; l > 0; optptr++, l--) { |
280 | if (*optptr != IPOPT_END) { | 280 | if (*optptr != IPOPT_END) { |
281 | *optptr = IPOPT_END; | 281 | *optptr = IPOPT_END; |
282 | opt->is_changed = 1; | 282 | opt->is_changed = 1; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | goto eol; | 285 | goto eol; |
286 | case IPOPT_NOOP: | 286 | case IPOPT_NOOP: |
287 | l--; | 287 | l--; |
288 | optptr++; | 288 | optptr++; |
289 | continue; | 289 | continue; |
290 | } | 290 | } |
291 | optlen = optptr[1]; | 291 | optlen = optptr[1]; |
292 | if (optlen<2 || optlen>l) { | 292 | if (optlen < 2 || optlen > l) { |
293 | pp_ptr = optptr; | 293 | pp_ptr = optptr; |
294 | goto error; | 294 | goto error; |
295 | } | 295 | } |
296 | switch (*optptr) { | 296 | switch (*optptr) { |
297 | case IPOPT_SSRR: | 297 | case IPOPT_SSRR: |
298 | case IPOPT_LSRR: | 298 | case IPOPT_LSRR: |
299 | if (optlen < 3) { | 299 | if (optlen < 3) { |
300 | pp_ptr = optptr + 1; | 300 | pp_ptr = optptr + 1; |
301 | goto error; | 301 | goto error; |
@@ -321,7 +321,7 @@ int ip_options_compile(struct net *net, | |||
321 | opt->is_strictroute = (optptr[0] == IPOPT_SSRR); | 321 | opt->is_strictroute = (optptr[0] == IPOPT_SSRR); |
322 | opt->srr = optptr - iph; | 322 | opt->srr = optptr - iph; |
323 | break; | 323 | break; |
324 | case IPOPT_RR: | 324 | case IPOPT_RR: |
325 | if (opt->rr) { | 325 | if (opt->rr) { |
326 | pp_ptr = optptr; | 326 | pp_ptr = optptr; |
327 | goto error; | 327 | goto error; |
@@ -349,7 +349,7 @@ int ip_options_compile(struct net *net, | |||
349 | } | 349 | } |
350 | opt->rr = optptr - iph; | 350 | opt->rr = optptr - iph; |
351 | break; | 351 | break; |
352 | case IPOPT_TIMESTAMP: | 352 | case IPOPT_TIMESTAMP: |
353 | if (opt->ts) { | 353 | if (opt->ts) { |
354 | pp_ptr = optptr; | 354 | pp_ptr = optptr; |
355 | goto error; | 355 | goto error; |
@@ -369,13 +369,13 @@ int ip_options_compile(struct net *net, | |||
369 | goto error; | 369 | goto error; |
370 | } | 370 | } |
371 | switch (optptr[3]&0xF) { | 371 | switch (optptr[3]&0xF) { |
372 | case IPOPT_TS_TSONLY: | 372 | case IPOPT_TS_TSONLY: |
373 | if (skb) | 373 | if (skb) |
374 | timeptr = &optptr[optptr[2]-1]; | 374 | timeptr = &optptr[optptr[2]-1]; |
375 | opt->ts_needtime = 1; | 375 | opt->ts_needtime = 1; |
376 | optptr[2] += 4; | 376 | optptr[2] += 4; |
377 | break; | 377 | break; |
378 | case IPOPT_TS_TSANDADDR: | 378 | case IPOPT_TS_TSANDADDR: |
379 | if (optptr[2]+7 > optptr[1]) { | 379 | if (optptr[2]+7 > optptr[1]) { |
380 | pp_ptr = optptr + 2; | 380 | pp_ptr = optptr + 2; |
381 | goto error; | 381 | goto error; |
@@ -389,7 +389,7 @@ int ip_options_compile(struct net *net, | |||
389 | opt->ts_needtime = 1; | 389 | opt->ts_needtime = 1; |
390 | optptr[2] += 8; | 390 | optptr[2] += 8; |
391 | break; | 391 | break; |
392 | case IPOPT_TS_PRESPEC: | 392 | case IPOPT_TS_PRESPEC: |
393 | if (optptr[2]+7 > optptr[1]) { | 393 | if (optptr[2]+7 > optptr[1]) { |
394 | pp_ptr = optptr + 2; | 394 | pp_ptr = optptr + 2; |
395 | goto error; | 395 | goto error; |
@@ -405,7 +405,7 @@ int ip_options_compile(struct net *net, | |||
405 | opt->ts_needtime = 1; | 405 | opt->ts_needtime = 1; |
406 | optptr[2] += 8; | 406 | optptr[2] += 8; |
407 | break; | 407 | break; |
408 | default: | 408 | default: |
409 | if (!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) { | 409 | if (!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) { |
410 | pp_ptr = optptr + 3; | 410 | pp_ptr = optptr + 3; |
411 | goto error; | 411 | goto error; |
@@ -433,7 +433,7 @@ int ip_options_compile(struct net *net, | |||
433 | } | 433 | } |
434 | opt->ts = optptr - iph; | 434 | opt->ts = optptr - iph; |
435 | break; | 435 | break; |
436 | case IPOPT_RA: | 436 | case IPOPT_RA: |
437 | if (optlen < 4) { | 437 | if (optlen < 4) { |
438 | pp_ptr = optptr + 1; | 438 | pp_ptr = optptr + 1; |
439 | goto error; | 439 | goto error; |
@@ -441,7 +441,7 @@ int ip_options_compile(struct net *net, | |||
441 | if (optptr[2] == 0 && optptr[3] == 0) | 441 | if (optptr[2] == 0 && optptr[3] == 0) |
442 | opt->router_alert = optptr - iph; | 442 | opt->router_alert = optptr - iph; |
443 | break; | 443 | break; |
444 | case IPOPT_CIPSO: | 444 | case IPOPT_CIPSO: |
445 | if ((!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) || opt->cipso) { | 445 | if ((!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) || opt->cipso) { |
446 | pp_ptr = optptr; | 446 | pp_ptr = optptr; |
447 | goto error; | 447 | goto error; |
@@ -452,9 +452,9 @@ int ip_options_compile(struct net *net, | |||
452 | goto error; | 452 | goto error; |
453 | } | 453 | } |
454 | break; | 454 | break; |
455 | case IPOPT_SEC: | 455 | case IPOPT_SEC: |
456 | case IPOPT_SID: | 456 | case IPOPT_SID: |
457 | default: | 457 | default: |
458 | if (!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) { | 458 | if (!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) { |
459 | pp_ptr = optptr; | 459 | pp_ptr = optptr; |
460 | goto error; | 460 | goto error; |
@@ -572,7 +572,7 @@ void ip_forward_options(struct sk_buff *skb) | |||
572 | 572 | ||
573 | optptr = raw + opt->srr; | 573 | optptr = raw + opt->srr; |
574 | 574 | ||
575 | for ( srrptr=optptr[2], srrspace = optptr[1]; | 575 | for ( srrptr = optptr[2], srrspace = optptr[1]; |
576 | srrptr <= srrspace; | 576 | srrptr <= srrspace; |
577 | srrptr += 4 | 577 | srrptr += 4 |
578 | ) { | 578 | ) { |
@@ -628,7 +628,7 @@ int ip_options_rcv_srr(struct sk_buff *skb) | |||
628 | if (rt->rt_type != RTN_LOCAL) | 628 | if (rt->rt_type != RTN_LOCAL) |
629 | return -EINVAL; | 629 | return -EINVAL; |
630 | 630 | ||
631 | for (srrptr=optptr[2], srrspace = optptr[1]; srrptr <= srrspace; srrptr += 4) { | 631 | for (srrptr = optptr[2], srrspace = optptr[1]; srrptr <= srrspace; srrptr += 4) { |
632 | if (srrptr + 3 > srrspace) { | 632 | if (srrptr + 3 > srrspace) { |
633 | icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((opt->srr+2)<<24)); | 633 | icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((opt->srr+2)<<24)); |
634 | return -EINVAL; | 634 | return -EINVAL; |