diff options
Diffstat (limited to 'networking/udhcp/common.c')
-rw-r--r-- | networking/udhcp/common.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 7929950f5..b325c4112 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -424,7 +424,6 @@ int FAST_FUNC udhcp_str2nip(const char *str, void *arg) | |||
424 | void* FAST_FUNC udhcp_insert_new_option( | 424 | void* FAST_FUNC udhcp_insert_new_option( |
425 | struct option_set **opt_list, | 425 | struct option_set **opt_list, |
426 | unsigned code, | 426 | unsigned code, |
427 | const void *buffer, | ||
428 | unsigned length, | 427 | unsigned length, |
429 | bool dhcpv6) | 428 | bool dhcpv6) |
430 | { | 429 | { |
@@ -434,17 +433,15 @@ void* FAST_FUNC udhcp_insert_new_option( | |||
434 | log2("attaching option %02x to list", code); | 433 | log2("attaching option %02x to list", code); |
435 | new = xmalloc(sizeof(*new)); | 434 | new = xmalloc(sizeof(*new)); |
436 | if (!dhcpv6) { | 435 | if (!dhcpv6) { |
437 | new->data = xmalloc(length + OPT_DATA); | 436 | new->data = xzalloc(length + OPT_DATA); |
438 | new->data[OPT_CODE] = code; | 437 | new->data[OPT_CODE] = code; |
439 | new->data[OPT_LEN] = length; | 438 | new->data[OPT_LEN] = length; |
440 | memcpy(new->data + OPT_DATA, buffer, length); | ||
441 | } else { | 439 | } else { |
442 | new->data = xmalloc(length + D6_OPT_DATA); | 440 | new->data = xzalloc(length + D6_OPT_DATA); |
443 | new->data[D6_OPT_CODE] = code >> 8; | 441 | new->data[D6_OPT_CODE] = code >> 8; |
444 | new->data[D6_OPT_CODE + 1] = code & 0xff; | 442 | new->data[D6_OPT_CODE + 1] = code & 0xff; |
445 | new->data[D6_OPT_LEN] = length >> 8; | 443 | new->data[D6_OPT_LEN] = length >> 8; |
446 | new->data[D6_OPT_LEN + 1] = length & 0xff; | 444 | new->data[D6_OPT_LEN + 1] = length & 0xff; |
447 | memcpy(new->data + D6_OPT_DATA, buffer, length); | ||
448 | } | 445 | } |
449 | 446 | ||
450 | curr = opt_list; | 447 | curr = opt_list; |
@@ -498,7 +495,11 @@ static NOINLINE void attach_option( | |||
498 | existing = udhcp_find_option(*opt_list, optflag->code); | 495 | existing = udhcp_find_option(*opt_list, optflag->code); |
499 | if (!existing) { | 496 | if (!existing) { |
500 | /* make a new option */ | 497 | /* make a new option */ |
501 | udhcp_insert_new_option(opt_list, optflag->code, buffer, length, dhcpv6); | 498 | uint8_t *p = udhcp_insert_new_option(opt_list, optflag->code, length, dhcpv6); |
499 | if (!dhcpv6) | ||
500 | memcpy(p + OPT_DATA, buffer, length); | ||
501 | else | ||
502 | memcpy(p + D6_OPT_DATA, buffer, length); | ||
502 | goto ret; | 503 | goto ret; |
503 | } | 504 | } |
504 | 505 | ||