diff --git a/apache2/msc_json.c b/apache2/msc_json.c index db7aa207..e2af2bb4 100644 --- a/apache2/msc_json.c +++ b/apache2/msc_json.c @@ -70,7 +70,7 @@ int json_add_argument(modsec_rec *msr, const char *value, unsigned length) * Callback for hash key values; we use those to define the variable names * under ARGS. Whenever we reach a new key, we update the current key value. */ -static int yajl_map_key(void *ctx, const unsigned char *key, unsigned int length) +static int yajl_map_key(void *ctx, const unsigned char *key, size_t length) { modsec_rec *msr = (modsec_rec *) ctx; unsigned char *safe_key = (unsigned char *) NULL; @@ -126,7 +126,7 @@ static int yajl_boolean(void *ctx, int value) /** * Callback for string values */ -static int yajl_string(void *ctx, const unsigned char *value, unsigned int length) +static int yajl_string(void *ctx, const unsigned char *value, size_t length) { modsec_rec *msr = (modsec_rec *) ctx; @@ -138,7 +138,7 @@ static int yajl_string(void *ctx, const unsigned char *value, unsigned int lengt * float/double values, but since we are not interested in using the numeric * values here, we use a generic handler which uses numeric strings */ -static int yajl_number(void *ctx, const unsigned char *value, unsigned int length) +static int yajl_number(void *ctx, const char *value, size_t length) { modsec_rec *msr = (modsec_rec *) ctx; @@ -222,19 +222,18 @@ int json_init(modsec_rec *msr, char **error_msg) { /** * yajl configuration and callbacks */ - static yajl_parser_config config = { 0, 1 }; static yajl_callbacks callbacks = { yajl_null, yajl_boolean, - NULL /* yajl_integer */, - NULL /* yajl_double */, + NULL /* yajl_integer */, + NULL /* yajl_double */, yajl_number, yajl_string, yajl_start_map, yajl_map_key, yajl_end_map, NULL /* yajl_start_array */, - NULL /* yajl_end_array */ + NULL /* yajl_end_array */ }; if (error_msg == NULL) return -1; @@ -261,7 +260,7 @@ int json_init(modsec_rec *msr, char **error_msg) { if (msr->txcfg->debuglog_level >= 9) { msr_log(msr, 9, "yajl JSON parsing callback initialization"); } - msr->json->handle = yajl_alloc(&callbacks, &config, NULL, msr); + msr->json->handle = yajl_alloc(&callbacks, NULL, msr); return 1; } @@ -275,8 +274,7 @@ int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char /* Feed our parser and catch any errors */ msr->json->status = yajl_parse(msr->json->handle, buf, size); - if (msr->json->status != yajl_status_ok && - msr->json->status != yajl_status_insufficient_data) { + if (msr->json->status != yajl_status_ok) { /* We need to free the yajl error message later, how to do this? */ *error_msg = yajl_get_error(msr->json->handle, 0, buf, size); } @@ -294,9 +292,8 @@ int json_complete(modsec_rec *msr, char **error_msg) { *error_msg = NULL; /* Wrap up the parsing process */ - msr->json->status = yajl_parse_complete(msr->json->handle); - if (msr->json->status != yajl_status_ok && - msr->json->status != yajl_status_insufficient_data) { + msr->json->status = yajl_complete_parse(msr->json->handle); + if (msr->json->status != yajl_status_ok) { /* We need to free the yajl error message later, how to do this? */ *error_msg = yajl_get_error(msr->json->handle, 0, NULL, 0); }