Skip to content

Commit feea267

Browse files
authored
Merge pull request #3069 from owasp-modsecurity/revert-2957-v2/mst/yajl_compat
Revert "Compatibility with libyajl decoding the buffer inline"
2 parents 207366c + 7073c26 commit feea267

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

apache2/msc_json.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,17 +354,15 @@ int json_init(modsec_rec *msr, char **error_msg) {
354354
int 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-
// 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;
357+
base_offset=buf;
360358

361359
/* Feed our parser and catch any errors */
362-
msr->json->status = yajl_parse(msr->json->handle, (unsigned char*)base_offset, size);
360+
msr->json->status = yajl_parse(msr->json->handle, buf, size);
363361
if (msr->json->status != yajl_status_ok) {
364362
if (msr->json->depth_limit_exceeded) {
365363
*error_msg = "JSON depth limit exceeded";
366364
} else {
367-
char *yajl_err = yajl_get_error(msr->json->handle, 0, base_offset, size);
365+
char *yajl_err = yajl_get_error(msr->json->handle, 0, buf, size);
368366
*error_msg = apr_pstrdup(msr->mp, yajl_err);
369367
yajl_free_error(msr->json->handle, yajl_err);
370368
}

0 commit comments

Comments
 (0)