43 Commits

Author SHA1 Message Date
mohaoyuan ea39b8e64d 合入社区修改:fix: prevent NULL pointer dereference in cJSON_SetNumberHelper (#991)
Signed-off-by: mohaoyuan <mohaoyuan@h-partners.com>
2026-03-25 20:31:32 +08:00
mohaoyuan 9ed9019cba 从社区合入版本1.7.19
Signed-off-by: mohaoyuan <mohaoyuan@h-partners.com>
2025-11-07 16:11:39 +08:00
liukaii 210ce064b7 Added max recusrion depth for cJSONDuplicate to prevent stack exhaustion in case of circular reference
Signed-off-by: liukaii <liukai240@huawei.com>
Change-Id: I8a9429686433c53e14edcd50bbf49a14eb9f9d6c
2025-07-24 15:21:21 +08:00
liuyuxiu 3bc6c44998 tdd add
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-06-12 11:15:12 +08:00
liuyuxiu 07bbf94c1b revert bugfix
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-06-05 11:22:30 +08:00
liuyuxiu 7ef33e91c4 bugfix
Signed-off-by: liuyuxiu <1175395694@qq.com>
2025-05-20 18:14:39 +08:00
youbing54 63e50e3853 IssueNo: https://gitee.com/openharmony/third_party_cJSON/issues/IC7ESI
describe: 回退64位修改
Feature or Bugfix: Bugfix
Binary Source:Yes
Signed-off-by: youbing54<youbing3@huawei.com>
2025-05-13 14:30:05 +08:00
youbing54 a20bc3ab70 IssueNo: https://gitee.com/openharmony/third_party_cJSON/issues/IC740N
describe: CVE-2023-26819 代码回退
Feature or Bugfix: Bugfix
Binary Source:Yes
Signed-off-by: youbing54<youbing3@huawei.com>
2025-05-12 15:34:18 +08:00
jiangtao57 9e0012644b fix 【漏洞修复】 CVE-2023-26819
Signed-off-by: jiangtao57 <jiangtao57@huawei.com>
Change-Id: I34a9b7a2e4800aca7cc91635bd2414639f9c42de
2025-05-09 21:04:13 +08:00
borne ac1e4b1368 feat: add int64 support
Offering: Open Source Institute

This commit adds int64 support for cjson. To enable int64, you need to define the macro ENABLE_INT64. To make it more clear, you need to build cjson like this if you are using makefile:

mkdir build
cd build
cmake -DENABLE_INT64=ON ..
make

This implementation changed the type of valueint in struct cJSON: from int to long long(int64), and added a new flag cJSON_IsInt64.
For a int64 cJSON item, the value of item->type would be cJSON_Number | cJSON_IsInt64.

The existing functions parse_number and print_number can handle int64 now.

Considering we have added a new type cJSON_IsInt64, some new functions have been added:
CJSON_PUBLIC(long long *) cJSON_GetInt64NumberValue(cJSON * const item)
CJSON_PUBLIC(cJSON_bool) cJSON_IsInt64Number(const cJSON * const item)
CJSON_PUBLIC(cJSON *) cJSON_CreateInt64Number(long long integer)
CJSON_PUBLIC(cJSON*) cJSON_AddInt64NumberToObject(cJSON * const object, const char * const name, const long long integer)
CJSON_PUBLIC(long long) cJSON_SetInt64NumberValue(cJSON * const object, const long long integer)

And some existing functions are also adjusted for int64, including parse_number, cJSON_SetNumberHelper, print_number, cJSON_CreateNumber, cJSON_Compare and compare_json(in cJSON_Utils).

Besides the code changes, we have also added some testcases for int64.
These tests will run if ENABLE_INT64 is turned on.

Ref:PeterAlfredLee
https://github.com/DaveGamble/cJSON/pull/689

Signed-off-by: borne <bo.lu@huawei.com>
2024-06-21 13:05:42 +08:00
liubo 1a6a39119e Description: 漏洞处理
IssueNo:https://gitee.com/openharmony/third_party_cJSON/issues/I8S4Y8
Feature or Bugfix: Bugfix
Binary Source:No
Signed-off-by: liubo419 <liubo419@huawei.com>
2023-12-28 17:40:30 +08:00
w00845693 7a7ebff009 Description: updata user guide
IssueNo: https://gitee.com/openharmony/third_party_cJSON/issues/I8JGFE
Feature or Bugfix: Feature
Binary Source:No
Signed-off-by: wyk99 <wangyuekai1@huawei.com>
2023-11-27 09:46:09 +08:00
mamingshuai a006830083 update openharmony 1.0.1 2021-03-11 20:34:23 +08:00
wenjun 2c251595b3 add OpenHarmony 1.0 baseline 2020-09-09 09:26:41 +08:00
Alan Wang 8813f0097d Merge pull request #453 from Alanscut/add-return-value
add return value for  cJSON_AddItemTo... and cJSON_ReplaceItemxxx
2020-04-02 19:41:56 +08:00
Alan Wang 356e3017c8 Merge pull request #451 from Alanscut/20200324
add new function of `cJSON_SetValuestring`
2020-04-02 19:40:03 +08:00
Sang-Heon Jeon 82e2998955 Add getNumberValue function
* Add GetNumberValue function and testcase

Co-authored-by: Alan Wang <wp_scut@163.com>
2020-04-02 19:36:35 +08:00
Alanscut 8e56349501 update testcase 2020-04-02 11:06:47 +08:00
Alanscut 9e18bf3836 false has been redefined to cJSON_False 2020-04-01 19:19:00 +08:00
Alanscut 0f7551e802 add return value for cJSON_AddItemTo... 2020-03-26 14:18:52 +08:00
Alanscut b31955beb8 update cJSON_SetValuestring and testcase 2020-03-25 15:38:54 +08:00
Alanscut 637e5b4f0d add testcase for cJSON_SetValuestringToObject 2020-03-24 22:28:27 +08:00
Alan Wang 581c0decbd Improve performance of adding item to array (#448)
* use prev pointer when adding item to array

Co-authored-by: xiaomianhehe <hongshaokai@hotmail.com>
Co-authored-by: Alanscut <scut@163.com>

Date:   Tue Feb 18 11:54:23 2020 +0800

* add testcase for cJSON_DeleteItemFromArray
2020-03-24 16:17:25 +08:00
Alan Wang a7da4d9079 Revert "use prev pointer when array do adding (#430)"
This reverts commit bb610a77a3.
2020-03-16 23:04:39 +08:00
xiaomianhehe bb610a77a3 use prev pointer when array do adding (#430)
* use prev pointer when array do adding
2020-02-18 11:54:23 +08:00
Max Bruckner 50eb763a0d Fix crash of cJSON_GetObjectItemCaseSensitive when calling it on arrays 2018-12-16 11:06:40 +01:00
Zach Hindes 4ddd0a8ffb Support default __stdcall calling convention on tests as well 2018-09-12 15:32:30 -05:00
Max Bruckner ce7ebfb3bf add_item_to_object: Fix use-after-free when string is aliased
If the `string` property of the item that is added is an alias to the
`string` parameter of `add_item_to_object`, and `constant` is false,
`cJSON_strdup` would access the string after it has been freed.

Thanks @hhallen for reporting this in #248.
2018-03-02 19:49:55 +01:00
Max Bruckner fabf89b60d Add cJSON_Create{Array,Object}Reference 2017-11-28 03:06:02 +01:00
Max Bruckner 525f500aba Add cJSON_CreateStringReference 2017-11-28 02:02:55 +01:00
Max Bruckner c28233d8b3 cJSON_GetStringValue 2017-11-15 18:47:49 +01:00
Max Bruckner 156a258308 Merge branch 'develop' 2017-10-08 22:05:02 +02:00
Max Bruckner 954d61e5e7 Fix #189, ensure returns an invalid pointer
If realloc returns NULL, ensure didn't abort but returned
printbuffer.offset instead. If an attacker can control
printbuffer.offset and also make realloc fail at just the right moment,
this would make cJSON potentially write at an arbitrary memory address.
2017-07-12 23:02:31 +02:00
Max Bruckner 5baa77f86c cJSON_Parse{,WithOpts}: Skip UTF-8 (Byte Order Marks) 2017-07-03 22:28:04 +02:00
Max Bruckner bdd5ff7ad6 misc_tests: Call all functions with NULL pointers 2017-06-28 14:22:42 +02:00
Max Bruckner 9ecc96878f fix #174: cJSON_ReplaceItemInObject doesn't copy name 2017-05-22 22:55:05 +02:00
Max Bruckner 8b953d1202 Add cJSON_ReplaceItemViaPointer 2017-05-02 01:18:55 +02:00
Max Bruckner c24c3e0285 Add cJSON_DetachItemViaPointer 2017-05-01 23:58:04 +02:00
Max Bruckner 28570ad095 Add test for cJSON_SetNumberHelper 2017-04-28 14:41:24 +02:00
Max Bruckner e0d3a8a265 Limit nesting depth to 1000 and make it configurable. 2017-04-27 01:57:45 +02:00
Max Bruckner c45dc12fd7 Tests for typecheck functions 2017-02-26 21:54:01 +01:00
Max Bruckner 56b819bfbc tests: test cJSON_GetObjectItem and cJSON_GetObjectItemCaseSensitive 2017-02-21 11:17:08 +01:00
Max Bruckner cbbcc91498 tests: cJSON_ArrayForEach 2017-02-21 09:17:49 +01:00