mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Fix memory leak that occurs on JSON parsing error
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,6 +1,8 @@
|
|||||||
DD mmm YYYY - 2.9.x (to be released)
|
DD mmm YYYY - 2.9.x (to be released)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Fix memory leak that occurs on JSON parsing error
|
||||||
|
[Issue #2236 @argenet, @vloup, @martinhsv]
|
||||||
* Multipart names/filenames may include single quote if double-quote enclosed
|
* Multipart names/filenames may include single quote if double-quote enclosed
|
||||||
[Issue #2352 @martinhsv]
|
[Issue #2352 @martinhsv]
|
||||||
* Add SecRequestBodyJsonDepthLimit to modsecurity.conf-recommended
|
* Add SecRequestBodyJsonDepthLimit to modsecurity.conf-recommended
|
||||||
|
@@ -351,11 +351,12 @@ int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char
|
|||||||
/* Feed our parser and catch any errors */
|
/* Feed our parser and catch any errors */
|
||||||
msr->json->status = yajl_parse(msr->json->handle, buf, size);
|
msr->json->status = yajl_parse(msr->json->handle, buf, size);
|
||||||
if (msr->json->status != yajl_status_ok) {
|
if (msr->json->status != yajl_status_ok) {
|
||||||
/* We need to free the yajl error message later, how to do this? */
|
|
||||||
if (msr->json->depth_limit_exceeded) {
|
if (msr->json->depth_limit_exceeded) {
|
||||||
*error_msg = "JSON depth limit exceeded";
|
*error_msg = "JSON depth limit exceeded";
|
||||||
} else {
|
} else {
|
||||||
*error_msg = yajl_get_error(msr->json->handle, 0, NULL, 0);
|
char *yajl_err = yajl_get_error(msr->json->handle, 0, buf, size);
|
||||||
|
*error_msg = apr_pstrdup(msr->mp, yajl_err);
|
||||||
|
yajl_free_error(msr->json->handle, yajl_err);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -375,11 +376,12 @@ int json_complete(modsec_rec *msr, char **error_msg) {
|
|||||||
/* Wrap up the parsing process */
|
/* Wrap up the parsing process */
|
||||||
msr->json->status = yajl_complete_parse(msr->json->handle);
|
msr->json->status = yajl_complete_parse(msr->json->handle);
|
||||||
if (msr->json->status != yajl_status_ok) {
|
if (msr->json->status != yajl_status_ok) {
|
||||||
/* We need to free the yajl error message later, how to do this? */
|
|
||||||
if (msr->json->depth_limit_exceeded) {
|
if (msr->json->depth_limit_exceeded) {
|
||||||
*error_msg = "JSON depth limit exceeded";
|
*error_msg = "JSON depth limit exceeded";
|
||||||
} else {
|
} else {
|
||||||
*error_msg = yajl_get_error(msr->json->handle, 0, NULL, 0);
|
char *yajl_err = yajl_get_error(msr->json->handle, 0, NULL, 0);
|
||||||
|
*error_msg = apr_pstrdup(msr->mp, yajl_err);
|
||||||
|
yajl_free_error(msr->json->handle, yajl_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user