From: John Wolfe Date: Mon, 5 Apr 2021 16:01:42 +0000 (-0700) Subject: JSMN: Miscellaneous log message fixes. X-Git-Tag: stable-11.3.0~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08d82bad0db6d0d04b257748e8434a28f5a7c1c4;p=thirdparty%2Fopen-vm-tools.git JSMN: Miscellaneous log message fixes. * One log message in jsmn_parse_string function referred to a primitive instead of a string. * When the parsing fails, the log message specified the wrong position where the parsing failed. * Changed '%c' to '0x%02x' in the log messages to avoid any issues with printing the invalid/unprintable characters. * Added a new log message for better debugging in one specific error code path. --- diff --git a/open-vm-tools/lib/jsmn/jsmn.c b/open-vm-tools/lib/jsmn/jsmn.c index ec1f5b41d..21c803e93 100644 --- a/open-vm-tools/lib/jsmn/jsmn.c +++ b/open-vm-tools/lib/jsmn/jsmn.c @@ -96,11 +96,11 @@ static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, goto found; } if (js[parser->pos] < 32 || js[parser->pos] >= 127) { - parser->pos = start; /* vmware */ - Log("%s: Unexpected char '%c' in primitive at pos %d\n", + Log("%s: Unexpected char '0x%02x' in primitive at pos %d\n", __FUNCTION__, js[parser->pos], parser->pos); /* vmware */ + parser->pos = start; return JSMN_ERROR_INVAL; } } @@ -177,11 +177,12 @@ static int jsmn_parse_string(jsmn_parser *parser, const char *js, if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ - parser->pos = start; /* vmware */ - Log("%s: Unexpected char '%c' in escaped unicode at pos %d\n", + Log("%s: Unexpected char '0x%02x' in escaped unicode " + "at pos %d\n", __FUNCTION__, js[parser->pos], parser->pos); /* vmware */ + parser->pos = start; return JSMN_ERROR_INVAL; } parser->pos++; @@ -190,11 +191,11 @@ static int jsmn_parse_string(jsmn_parser *parser, const char *js, break; /* Unexpected symbol */ default: - parser->pos = start; /* vmware */ - Log("%s: Unexpected symbol '%c' in primitive at pos %d\n", + Log("%s: Unexpected symbol '0x%02x' in string at pos %d\n", __FUNCTION__, js[parser->pos], parser->pos); /* vmware */ + parser->pos = start; return JSMN_ERROR_INVAL; } } @@ -347,6 +348,10 @@ int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, #ifdef JSMN_STRICT /* Unexpected char in strict mode */ default: + /* vmware */ + Log("%s: Unexpected char '0x%02x' at pos %d\n", + __FUNCTION__, js[parser->pos], parser->pos); + /* vmware */ return JSMN_ERROR_INVAL; #endif }