From: Ben Hutchings Date: Thu, 28 Jan 2016 22:45:14 +0000 (+0000) Subject: Fix regression in entry_to_env() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1801580e39ceac0d7fec7adef892763c4da56906;p=oweals%2Fodhcp6c.git Fix regression in entry_to_env() I broke entry_to_env() by incrementing the wrong variable in commit a6bbd1d7f5c2 ("Fix potential buffer overflow in entry_to_env"). Signed-off-by: Ben Hutchings --- diff --git a/src/script.c b/src/script.c index 3579331..5955e94 100644 --- a/src/script.c +++ b/src/script.c @@ -169,7 +169,7 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en buf_len += strlen(&buf[buf_len]); if (type != ENTRY_HOST) { snprintf(&buf[buf_len], 6, "/%"PRIu16, e[i].length); - buf += strlen(&buf[buf_len]); + buf_len += strlen(&buf[buf_len]); if (type == ENTRY_ROUTE) { buf[buf_len++] = ','; if (!IN6_IS_ADDR_UNSPECIFIED(&e[i].router)) { @@ -177,15 +177,15 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en buf_len += strlen(&buf[buf_len]); } snprintf(&buf[buf_len], 23, ",%u,%u", e[i].valid, e[i].priority); - buf += strlen(&buf[buf_len]); + buf_len += strlen(&buf[buf_len]); } else { snprintf(&buf[buf_len], 23, ",%u,%u", e[i].preferred, e[i].valid); - buf += strlen(&buf[buf_len]); + buf_len += strlen(&buf[buf_len]); } if (type == ENTRY_PREFIX && ntohl(e[i].iaid) != 1) { snprintf(&buf[buf_len], 16, ",class=%08x", ntohl(e[i].iaid)); - buf += strlen(&buf[buf_len]); + buf_len += strlen(&buf[buf_len]); } if (type == ENTRY_PREFIX && e[i].priority) {