diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-11-07 16:21:24 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-11-07 16:21:24 +0100 |
commit | 68c5b28156450d686605bd4715980037cabf1286 (patch) | |
tree | 3360e61ad92015c5a34819b1a9c177524c237c02 | |
parent | 9ba75048c0099ed90b9a64cb7bb57bf12be93528 (diff) | |
download | busybox-w32-68c5b28156450d686605bd4715980037cabf1286.tar.gz busybox-w32-68c5b28156450d686605bd4715980037cabf1286.tar.bz2 busybox-w32-68c5b28156450d686605bd4715980037cabf1286.zip |
udhcpc6: fix endianness
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/d6_common.h | 4 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h index 88afaf8af..36d822f7e 100644 --- a/networking/udhcp/d6_common.h +++ b/networking/udhcp/d6_common.h | |||
@@ -54,10 +54,10 @@ struct udp_d6_packet { | |||
54 | /*** Options ***/ | 54 | /*** Options ***/ |
55 | 55 | ||
56 | struct d6_option { | 56 | struct d6_option { |
57 | uint8_t code; | ||
58 | uint8_t code_hi; | 57 | uint8_t code_hi; |
59 | uint8_t len; | 58 | uint8_t code; |
60 | uint8_t len_hi; | 59 | uint8_t len_hi; |
60 | uint8_t len; | ||
61 | uint8_t data[1]; | 61 | uint8_t data[1]; |
62 | } PACKED; | 62 | } PACKED; |
63 | 63 | ||
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index d1baaae9b..62d79b363 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -97,20 +97,20 @@ static void *d6_find_option(uint8_t *option, uint8_t *option_end, unsigned code) | |||
97 | int len_m4 = option_end - option - 4; | 97 | int len_m4 = option_end - option - 4; |
98 | while (len_m4 >= 0) { | 98 | while (len_m4 >= 0) { |
99 | /* Next option's len is too big? */ | 99 | /* Next option's len is too big? */ |
100 | if (option[2] > len_m4) | 100 | if (option[3] > len_m4) |
101 | return NULL; /* yes. bogus packet! */ | 101 | return NULL; /* yes. bogus packet! */ |
102 | /* So far we treat any opts with code >255 | 102 | /* So far we treat any opts with code >255 |
103 | * or len >255 as bogus, and stop at once. | 103 | * or len >255 as bogus, and stop at once. |
104 | * This simplifies big-endian handling. | 104 | * This simplifies big-endian handling. |
105 | */ | 105 | */ |
106 | if (option[1] != 0 || option[3] != 0) | 106 | if (option[0] != 0 || option[2] != 0) |
107 | return NULL; | 107 | return NULL; |
108 | /* Option seems to be valid */ | 108 | /* Option seems to be valid */ |
109 | /* Does its code match? */ | 109 | /* Does its code match? */ |
110 | if (option[0] == code) | 110 | if (option[1] == code) |
111 | return option; /* yes! */ | 111 | return option; /* yes! */ |
112 | option += option[2] + 4; | 112 | option += option[3] + 4; |
113 | len_m4 -= option[2] + 4; | 113 | len_m4 -= option[3] + 4; |
114 | } | 114 | } |
115 | return NULL; | 115 | return NULL; |
116 | } | 116 | } |
@@ -120,7 +120,7 @@ static void *d6_copy_option(uint8_t *option, uint8_t *option_end, unsigned code) | |||
120 | uint8_t *opt = d6_find_option(option, option_end, code); | 120 | uint8_t *opt = d6_find_option(option, option_end, code); |
121 | if (!opt) | 121 | if (!opt) |
122 | return opt; | 122 | return opt; |
123 | return memcpy(xmalloc(opt[2] + 4), opt, opt[2] + 4); | 123 | return memcpy(xmalloc(opt[3] + 4), opt, opt[3] + 4); |
124 | } | 124 | } |
125 | 125 | ||
126 | static void *d6_store_blob(void *dst, const void *src, unsigned len) | 126 | static void *d6_store_blob(void *dst, const void *src, unsigned len) |
@@ -920,8 +920,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
920 | clientid = xzalloc(2+2+2+2+6); | 920 | clientid = xzalloc(2+2+2+2+6); |
921 | clientid->code = D6_OPT_CLIENTID; | 921 | clientid->code = D6_OPT_CLIENTID; |
922 | clientid->len = 2+2+6; | 922 | clientid->len = 2+2+6; |
923 | clientid->data[0] = 3; /* DUID-LL */ | 923 | clientid->data[1] = 3; /* DUID-LL */ |
924 | clientid->data[2] = 1; /* ethernet */ | 924 | clientid->data[3] = 1; /* ethernet */ |
925 | clientid_mac_ptr = clientid->data + 2+2; | 925 | clientid_mac_ptr = clientid->data + 2+2; |
926 | memcpy(clientid_mac_ptr, client_config.client_mac, 6); | 926 | memcpy(clientid_mac_ptr, client_config.client_mac, 6); |
927 | client_config.clientid = (void*)clientid; | 927 | client_config.clientid = (void*)clientid; |