json_script: fix eval_string().
authorYousong Zhou <[email protected]>
Wed, 12 Nov 2014 13:59:22 +0000 (21:59 +0800)
committerFelix Fietkau <[email protected]>
Thu, 11 Dec 2014 16:59:02 +0000 (17:59 +0100)
- Fix handling of "%%".
 - Fix length requirement when calling blobmsg_realloc_string_buffer().

Signed-off-by: Yousong Zhou <[email protected]>
json_script.c

index 0ec7b382ad94d4bbdb64156210243513af9daf30..8e7f5265ed4d42e9a784b6bcef14b818e6bebe78 100644 (file)
@@ -416,7 +416,7 @@ static int eval_string(struct json_call *call, struct blob_buf *buf, const char
                }
 
                if (cur_var) {
-                       if (next > str) {
+                       if (end > str) {
                                cur = msg_find_var(call, str);
                                if (!cur)
                                        continue;
@@ -434,7 +434,7 @@ static int eval_string(struct json_call *call, struct blob_buf *buf, const char
                        cur_len = end - str;
                }
 
-               dest = blobmsg_realloc_string_buffer(buf, cur_len + 1);
+               dest = blobmsg_realloc_string_buffer(buf, len + cur_len + 1);
                memcpy(dest + len, cur, cur_len);
                len += cur_len;
        }