added json format validation to read_socket_raw

This commit is contained in:
Václav Šmejkal 2024-08-30 13:41:01 +02:00
parent 3fc339a9fb
commit 8bd3df1ae1
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -188,7 +188,20 @@ char *read_socket_raw(int socket)
return_section:
content_buffer[content_size] = '\0';
content_buffer[content_size] = '\0'; //NULL TERM
//VALIDATE JSON FORMAT
struct json_object *json = json_tokener_parse(content_buffer);
if (json == NULL)
{
//RESET content_buffer
why2_deallocate(content_buffer);
content_buffer = NULL;
} else
{
//DEALLOCATION
json_object_put(json);
}
return content_buffer;
}