Compare commits

..

4 Commits

Author SHA1 Message Date
Max Bruckner
de5df3e56f Release version 1.5.2 2017-05-10 02:25:25 +02:00
Max Bruckner
a167d9e381 Fix reading buffer overflow in parse_string 2017-05-10 02:09:01 +02:00
Max Bruckner
b537ca70a3 old_utils_tests: Remove leftover unused attribute 2017-05-10 01:15:28 +02:00
Max Bruckner
186cce3ece Fix -Wcomma 2017-05-10 00:52:33 +02:00
6 changed files with 22 additions and 12 deletions

View File

@@ -1,3 +1,11 @@
1.5.2
=====
Fixes:
------
* Fix a reading buffer overflow in `parse_string` (a167d9e381e5c84bc03de4e261757b031c0c690d)
* Fix compiling with -Wcomma (186cce3ece6ce6dfcb58ac8b2a63f7846c3493ad)
* Remove leftover attribute from tests (b537ca70a35680db66f1f5b8b437f7114daa699a)
1.5.1 1.5.1
===== =====
Fixes: Fixes:

View File

@@ -7,7 +7,7 @@ project(cJSON C)
set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 5) set(PROJECT_VERSION_MINOR 5)
set(PROJECT_VERSION_PATCH 1) set(PROJECT_VERSION_PATCH 2)
set(CJSON_VERSION_SO 1) set(CJSON_VERSION_SO 1)
set(CJSON_UTILS_VERSION_SO 1) set(CJSON_UTILS_VERSION_SO 1)
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

View File

@@ -8,7 +8,7 @@ CJSON_TEST_SRC = cJSON.c test.c
LDLIBS = -lm LDLIBS = -lm
LIBVERSION = 1.5.1 LIBVERSION = 1.5.2
CJSON_SOVERSION = 1 CJSON_SOVERSION = 1
UTILS_SOVERSION = 1 UTILS_SOVERSION = 1

18
cJSON.c
View File

@@ -58,7 +58,7 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
} }
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ /* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 5) || (CJSON_VERSION_PATCH != 1) #if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 5) || (CJSON_VERSION_PATCH != 2)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same. #error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif #endif
@@ -657,7 +657,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
/* calculate approximate size of the output (overestimate) */ /* calculate approximate size of the output (overestimate) */
size_t allocation_length = 0; size_t allocation_length = 0;
size_t skipped_bytes = 0; size_t skipped_bytes = 0;
while ((*input_end != '\"') && ((size_t)(input_end - input_buffer->content) < input_buffer->length)) while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"'))
{ {
/* is escape sequence */ /* is escape sequence */
if (input_end[0] == '\\') if (input_end[0] == '\\')
@@ -672,7 +672,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
} }
input_end++; input_end++;
} }
if (*input_end != '\"') if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"'))
{ {
goto fail; /* string ended unexpectedly */ goto fail; /* string ended unexpectedly */
} }
@@ -2560,16 +2560,18 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
case cJSON_Array: case cJSON_Array:
{ {
cJSON *a_element = NULL; cJSON *a_element = a->child;
cJSON *b_element = NULL; cJSON *b_element = b->child;
for (a_element = a->child, b_element = b->child;
(a_element != NULL) && (b_element != NULL); for (; (a_element != NULL) && (b_element != NULL);)
a_element = a_element->next, b_element = b_element->next)
{ {
if (!cJSON_Compare(a_element, b_element, case_sensitive)) if (!cJSON_Compare(a_element, b_element, case_sensitive))
{ {
return false; return false;
} }
a_element = a_element->next;
b_element = b_element->next;
} }
return true; return true;

View File

@@ -31,7 +31,7 @@ extern "C"
/* project version */ /* project version */
#define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 5 #define CJSON_VERSION_MINOR 5
#define CJSON_VERSION_PATCH 1 #define CJSON_VERSION_PATCH 2
#include <stddef.h> #include <stddef.h>

View File

@@ -30,7 +30,7 @@
#include "../cJSON_Utils.h" #include "../cJSON_Utils.h"
/* JSON Apply Merge tests: */ /* JSON Apply Merge tests: */
const char *merges[15][3] = static const char *merges[15][3] =
{ {
{"{\"a\":\"b\"}", "{\"a\":\"c\"}", "{\"a\":\"c\"}"}, {"{\"a\":\"b\"}", "{\"a\":\"c\"}", "{\"a\":\"c\"}"},
{"{\"a\":\"b\"}", "{\"b\":\"c\"}", "{\"a\":\"b\",\"b\":\"c\"}"}, {"{\"a\":\"b\"}", "{\"b\":\"c\"}", "{\"a\":\"b\",\"b\":\"c\"}"},