Skip to content
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

infinite loop of cJSON_Minify function in version 1.7.11 #354

Closed
Alanscut opened this issue May 16, 2019 · 2 comments
Closed

infinite loop of cJSON_Minify function in version 1.7.11 #354

Alanscut opened this issue May 16, 2019 · 2 comments
Labels

Comments

@Alanscut
Copy link
Collaborator

Hi, Max @FSMaxB , I encountered an infinite loop when I used the '/' character alone(not // or /*).
this is my test demo:

int main(void)
{
        char str[] = { '8', ' ', '/', ' ', '5', '\n' };
	cJSON_Minify(str);
	printf("after minify, str: %s\n", str);

	return 0;
}

the program will not end.
The cJSON_Minify() function does not stop if the input string contains the '/' character. Since line 2712 of the cJSON.c file mistakenly thinks that it is going to enter the comment part, and in fact "/" is not necessarily the beginning of the comment, then Break jumps out of the switch statement and enters the while loop again, forming an infinite loop.
image

@FSMaxB FSMaxB added the bug label May 16, 2019
@FSMaxB
Copy link
Collaborator

FSMaxB commented May 16, 2019

Well that is embarrassing ...
I'll take a look and try to fix this bug!

Please not that your test code also has a bug, since there is no '\0' at the end of your string.

@FSMaxB
Copy link
Collaborator

FSMaxB commented May 16, 2019

Fixed in cJSON 1.7.12

@FSMaxB FSMaxB closed this as completed May 16, 2019
buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this issue May 18, 2019
Fix infinite loop in cJSON_Minify (potential Denial of Service), see
DaveGamble/cJSON#354

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
texierp pushed a commit to texierp/buildroot that referenced this issue Jun 2, 2019
Fix infinite loop in cJSON_Minify (potential Denial of Service), see
DaveGamble/cJSON#354

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this issue Jun 6, 2019
Fix infinite loop in cJSON_Minify (potential Denial of Service), see
DaveGamble/cJSON#354

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 2ee83e0)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
igrr pushed a commit to espressif/esp-idf that referenced this issue Aug 27, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
igrr pushed a commit to espressif/esp-idf that referenced this issue Aug 30, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
igrr pushed a commit to espressif/esp-idf that referenced this issue Sep 5, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
igrr pushed a commit to espressif/esp-idf that referenced this issue Sep 16, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
wujiangang pushed a commit to espressif/ESP8266_RTOS_SDK that referenced this issue Sep 18, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354

Using submodule instead of source code.
igrr pushed a commit to espressif/esp-idf that referenced this issue Sep 21, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
igrr pushed a commit to espressif/esp-idf that referenced this issue Sep 29, 2019
Fixes potential DoS in cJSON_Minify, see DaveGamble/cJSON#354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants