From 0c5ef21c10861a2ebd1f4ca49c1f872f390245e8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 3 Nov 2015 22:53:19 +0100 Subject: [PATCH] CID 22434 Ignoring number of bytes read also potential missing null-termination --- src/kernel/jsonconf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 9e23c3360..4602008f5 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -839,8 +839,9 @@ static void json_include(cJSON *json) { fseek(F, 0, SEEK_END); sz = ftell(F); rewind(F); - data = malloc(sz); - fread(data, 1, sz, F); + data = malloc(sz+1); + sz = fread(data, 1, sz, F); + data[sz] = 0; fclose(F); config = cJSON_Parse(data); free(data);