X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fjson.c;h=37bdece5c1b1555fa9087c9ba9360f83d7dc6f64;hb=d0040604727e1582abbc28fa62903a822453c99f;hp=5887f677a42d731f71ade48ea1368f196bcb2c9d;hpb=2a022368f4b37559de5d5621a88c648023493f75;p=openvswitch diff --git a/lib/json.c b/lib/json.c index 5887f677..37bdece5 100644 --- a/lib/json.c +++ b/lib/json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "dynamic-string.h" @@ -746,19 +745,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";