summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-06-14 20:31:18 -0700
committerGary E. Miller <gem@rellim.com>2018-06-14 20:31:18 -0700
commita968ebb3842be50ceef9862a786f0784b2324cd5 (patch)
tree0cf5c960eafe5cf15a6bcf7366fe8013a27b70a6 /json.c
parent9b3724cb7bca7a0776bcb9b054cd1d8d736278a4 (diff)
downloadgpsd-a968ebb3842be50ceef9862a786f0784b2324cd5.tar.gz
json.c Allow for \u escapes with fewer than 4 digits.
\u0, \u00, \u000 and \u000. The next charbetter be non-hex.
Diffstat (limited to 'json.c')
-rw-r--r--json.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/json.c b/json.c
index 5c4dd3de..81a3bac5 100644
--- a/json.c
+++ b/json.c
@@ -392,12 +392,14 @@ static int json_internal_read_object(const char *cp,
*pval++ = '\t';
break;
case 'u':
- for (n = 0; n < 4 && cp[n] != '\0'; n++)
+ cp++; /* skip the 'u' */
+ for (n = 0; n < 4 && isxdigit(*cp); n++)
uescape[n] = *cp++;
- uescape[n] = '\0'; /* terminate */
+ uescape[n] = '\0'; /* terminate */
--cp;
- if (1 != sscanf(uescape, "%4x", &u))
+ if (1 != sscanf(uescape, "%4x", &u)) {
return JSON_ERR_BADSTRING;
+ }
*pval++ = (char)u; /* will truncate values above 0xff */
break;
default: /* handles double quote and solidus */