diff options
-rw-r--r-- | net/ipv4/ip_options.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index c3118e1cd3bb..ec93335901dd 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
17 | #include <asm/unaligned.h> | ||
17 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
18 | #include <linux/ip.h> | 19 | #include <linux/ip.h> |
19 | #include <linux/icmp.h> | 20 | #include <linux/icmp.h> |
@@ -350,7 +351,7 @@ int ip_options_compile(struct net *net, | |||
350 | goto error; | 351 | goto error; |
351 | } | 352 | } |
352 | if (optptr[2] <= optlen) { | 353 | if (optptr[2] <= optlen) { |
353 | __be32 *timeptr = NULL; | 354 | unsigned char *timeptr = NULL; |
354 | if (optptr[2]+3 > optptr[1]) { | 355 | if (optptr[2]+3 > optptr[1]) { |
355 | pp_ptr = optptr + 2; | 356 | pp_ptr = optptr + 2; |
356 | goto error; | 357 | goto error; |
@@ -359,7 +360,7 @@ int ip_options_compile(struct net *net, | |||
359 | case IPOPT_TS_TSONLY: | 360 | case IPOPT_TS_TSONLY: |
360 | opt->ts = optptr - iph; | 361 | opt->ts = optptr - iph; |
361 | if (skb) | 362 | if (skb) |
362 | timeptr = (__be32*)&optptr[optptr[2]-1]; | 363 | timeptr = &optptr[optptr[2]-1]; |
363 | opt->ts_needtime = 1; | 364 | opt->ts_needtime = 1; |
364 | optptr[2] += 4; | 365 | optptr[2] += 4; |
365 | break; | 366 | break; |
@@ -371,7 +372,7 @@ int ip_options_compile(struct net *net, | |||
371 | opt->ts = optptr - iph; | 372 | opt->ts = optptr - iph; |
372 | if (rt) { | 373 | if (rt) { |
373 | memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); | 374 | memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); |
374 | timeptr = (__be32*)&optptr[optptr[2]+3]; | 375 | timeptr = &optptr[optptr[2]+3]; |
375 | } | 376 | } |
376 | opt->ts_needaddr = 1; | 377 | opt->ts_needaddr = 1; |
377 | opt->ts_needtime = 1; | 378 | opt->ts_needtime = 1; |
@@ -389,7 +390,7 @@ int ip_options_compile(struct net *net, | |||
389 | if (inet_addr_type(net, addr) == RTN_UNICAST) | 390 | if (inet_addr_type(net, addr) == RTN_UNICAST) |
390 | break; | 391 | break; |
391 | if (skb) | 392 | if (skb) |
392 | timeptr = (__be32*)&optptr[optptr[2]+3]; | 393 | timeptr = &optptr[optptr[2]+3]; |
393 | } | 394 | } |
394 | opt->ts_needtime = 1; | 395 | opt->ts_needtime = 1; |
395 | optptr[2] += 8; | 396 | optptr[2] += 8; |
@@ -403,10 +404,10 @@ int ip_options_compile(struct net *net, | |||
403 | } | 404 | } |
404 | if (timeptr) { | 405 | if (timeptr) { |
405 | struct timespec tv; | 406 | struct timespec tv; |
406 | __be32 midtime; | 407 | u32 midtime; |
407 | getnstimeofday(&tv); | 408 | getnstimeofday(&tv); |
408 | midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC); | 409 | midtime = (tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC; |
409 | memcpy(timeptr, &midtime, sizeof(__be32)); | 410 | put_unaligned_be32(midtime, timeptr); |
410 | opt->is_changed = 1; | 411 | opt->is_changed = 1; |
411 | } | 412 | } |
412 | } else { | 413 | } else { |