Fix regression in entry_to_env()
authorBen Hutchings <ben@decadent.org.uk>
Thu, 28 Jan 2016 22:45:14 +0000 (22:45 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 28 Jan 2016 22:49:54 +0000 (22:49 +0000)
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 <ben@decadent.org.uk>
src/script.c

index 3579331..5955e94 100644 (file)
@@ -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) {