X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fjson.c;h=0a8bca27814ba692f817878dc2ccefca83e7e599;hb=f696f12fbe84f49d650f48c45ce1a24b94547ad2;hp=5887f677a42d731f71ade48ea1368f196bcb2c9d;hpb=2a022368f4b37559de5d5621a88c648023493f75;p=openvswitch diff --git a/lib/json.c b/lib/json.c index 5887f677..0a8bca27 100644 --- a/lib/json.c +++ b/lib/json.c @@ -746,19 +746,15 @@ json_lex_number(struct json_parser *p) static const char * json_lex_4hex(const char *cp, const char *end, int *valuep) { - int value, i; + unsigned int value; if (cp + 4 > end) { return "quoted string ends within \\u escape"; } - value = 0; - for (i = 0; i < 4; i++) { - unsigned char c = *cp++; - if (!isxdigit(c)) { - return "malformed \\u escape"; - } - value = (value << 4) | hexit_value(c); + value = hexits_value(cp, 4, NULL); + if (value == UINT_MAX) { + return "malformed \\u escape"; } if (!value) { return "null bytes not supported in quoted strings";