Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2022-05-12 14:22:56 +0300
committerFelix Fietkau <nbd@nbd.name>2022-05-12 14:26:29 +0300
commitcfa372ff8aed8257465adb5445f43656ace2d615 (patch)
tree1e32cc3f255feba71567114a406af5e703f39210 /json_script.c
parent45210ce14136d9410d7139fba816c4465b4c7af5 (diff)
blobmsg: implicitly reserve space for 0-terminator in string buf alloc
It may not be clear to all users of this API if the provided maxlen argument refers to the maximum string length or the maximum buffer size. In order to improve safety and convenience of this API, make it refer to the maximum string length. Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'json_script.c')
-rw-r--r--json_script.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/json_script.c b/json_script.c
index 14d045d..7177e9c 100644
--- a/json_script.c
+++ b/json_script.c
@@ -431,7 +431,7 @@ static int eval_string(struct json_call *call, struct blob_buf *buf, const char
bool var = false;
char c = '%';
- dest = blobmsg_alloc_string_buffer(buf, name, 1);
+ dest = blobmsg_alloc_string_buffer(buf, name, 0);
if (!dest)
return -1;
@@ -473,7 +473,7 @@ static int eval_string(struct json_call *call, struct blob_buf *buf, const char
cur_len = end - str;
}
- new_buf = blobmsg_realloc_string_buffer(buf, len + cur_len + 1);
+ new_buf = blobmsg_realloc_string_buffer(buf, len + cur_len);
if (!new_buf) {
/* Make eval_string return -1 */
var = true;