-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when parsing JSON in ESP-IDF project with cJSON library #875
Comments
This is impossible to do in a portable manner. Also, your spec is UB, you can't cast an invalid pointer value. It is safe to assume that your program won't work correctly if you invoke UB. C is a memory unsafe language. |
You're passing an invalid memory address to a public API function. It expects the caller to pass a pointer to a valid address. The function already checks for a null pointer value, and that's all it can do. There is no magic pointer validating in low-level code. The responsibility of not feeding garbage pointers is on the programmer who calls the API methods. This is not a philosophical question but a practical reality. |
Bug Report
Required Info:
Steps to reproduce issue:
Hi, while fuzz testing FreeRTOS using Syzkaller, I encountered an illegal memory access error in the
cJSON
module.this is my SPEC which can trigger the bug
Error Report
During the fuzzing process, I received the following error report:
It appears there is an illegal access at
components/json/cJSON/cJSON.c
in thecJSON_ParseWithOpts
function. The specific error occurs on this linebuffer_length = strlen(value) + sizeof("");
If the value string is pointing to an illegal memory address, then an illegal memory access occurs whenstrlen()
is called. So in this function you should first determine if the pointer is pointing to the correct memory address, and then call thestrlen()
function.Expected Behavior
The program should execute without any memory errors or crashes.
Actual Behavior
The program crashes with an unhandled exception indicating an illegal memory access error.
Additional Information
I would greatly appreciate it if you could review this bug report. Any suggestions or feedback you can provide would be very helpful. Thank you for your time.
The text was updated successfully, but these errors were encountered: