Skip to content

Commit ec61749

Browse files
author
Felipe Zimmerle
committed
Changes JSON parser to not accept parcial contents
Also cleanup installer file.
1 parent 966e7e1 commit ec61749

File tree

2 files changed

+426
-603
lines changed

2 files changed

+426
-603
lines changed

apache2/msc_json.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,15 @@ int json_init(modsec_rec *msr, char **error_msg) {
254254
* yajl initialization
255255
*
256256
* yajl_parser_config definition:
257-
* http://lloyd.github.com/yajl/yajl-1.0.12/structyajl__parser__config.html
257+
* http://lloyd.github.io/yajl/yajl-2.0.1/yajl__parse_8h.html#aec816c5518264d2ac41c05469a0f986c
258258
*
259259
* TODO: make UTF8 validation optional, as it depends on Content-Encoding
260260
*/
261261
if (msr->txcfg->debuglog_level >= 9) {
262262
msr_log(msr, 9, "yajl JSON parsing callback initialization");
263263
}
264264
msr->json->handle = yajl_alloc(&callbacks, NULL, msr);
265+
yajl_config(msr->json->handle, yajl_allow_partial_values, 0);
265266

266267
return 1;
267268
}
@@ -278,6 +279,7 @@ int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char
278279
if (msr->json->status != yajl_status_ok) {
279280
/* We need to free the yajl error message later, how to do this? */
280281
*error_msg = yajl_get_error(msr->json->handle, 0, buf, size);
282+
return -1;
281283
}
282284

283285
return 1;
@@ -297,6 +299,7 @@ int json_complete(modsec_rec *msr, char **error_msg) {
297299
if (msr->json->status != yajl_status_ok) {
298300
/* We need to free the yajl error message later, how to do this? */
299301
*error_msg = yajl_get_error(msr->json->handle, 0, NULL, 0);
302+
return -1;
300303
}
301304

302305
return 1;

0 commit comments

Comments
 (0)