File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -354,15 +354,17 @@ int json_init(modsec_rec *msr, char **error_msg) {
354354int json_process_chunk (modsec_rec * msr , const char * buf , unsigned int size , char * * error_msg ) {
355355 if (error_msg == NULL ) return -1 ;
356356 * error_msg = NULL ;
357- base_offset = buf ;
357+ // Take a copy in case libyajl decodes the buffer inline
358+ base_offset = apr_pstrmemdup (msr -> mp , buf , size );
359+ if (!base_offset ) return -1 ;
358360
359361 /* Feed our parser and catch any errors */
360- msr -> json -> status = yajl_parse (msr -> json -> handle , buf , size );
362+ msr -> json -> status = yajl_parse (msr -> json -> handle , ( unsigned char * ) base_offset , size );
361363 if (msr -> json -> status != yajl_status_ok ) {
362364 if (msr -> json -> depth_limit_exceeded ) {
363365 * error_msg = "JSON depth limit exceeded" ;
364366 } else {
365- char * yajl_err = yajl_get_error (msr -> json -> handle , 0 , buf , size );
367+ char * yajl_err = yajl_get_error (msr -> json -> handle , 0 , base_offset , size );
366368 * error_msg = apr_pstrdup (msr -> mp , yajl_err );
367369 yajl_free_error (msr -> json -> handle , yajl_err );
368370 }
You can’t perform that action at this time.
0 commit comments