forked from osmocom/wireshark
Also don't treat an empty buffer as JSON.
That also keeps us from looking at the non-existent first octet of an empty buffer. Bug: 16031 Change-Id: I3fcf4201d21dc44ccd8815cb0637c1eae4995560 Reviewed-on: https://code.wireshark.org/review/34439 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
6b28772660
commit
fd425b195c
|
@ -37,12 +37,16 @@ json_validate(const guint8 *buf, const size_t len)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the first octet isn't a NUL; otherwise, the parser will
|
* Make sure the buffer isn't empty and the first octet isn't a NUL;
|
||||||
* immediately stop parsing and not validate anything after that,
|
* otherwise, the parser will immediately stop parsing and not validate
|
||||||
* so it'll just think it was handed an empty string.
|
* anything after that, so it'll just think it was handed an empty string.
|
||||||
*
|
*
|
||||||
* XXX - should we check for NULs anywhere in the buffer?
|
* XXX - should we check for NULs anywhere in the buffer?
|
||||||
*/
|
*/
|
||||||
|
if (len == 0) {
|
||||||
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "jsmn: JSON string is empty");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (buf[0] == '\0') {
|
if (buf[0] == '\0') {
|
||||||
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "jsmn: invalid character inside JSON string");
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "jsmn: invalid character inside JSON string");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue