diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-17 09:43:20 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-17 09:43:20 -0500 |
commit | 904b568b169b8f21c3b380bc3a98b0f79f80c7db (patch) | |
tree | d55569ac132290faf8f1fe2cbefe436d668453d4 /json.c | |
parent | 1fadd3a923fa3a181ca00c23f7f7171f3ebd0488 (diff) | |
download | gpsd-904b568b169b8f21c3b380bc3a98b0f79f80c7db.tar.gz |
Prevent JSON parsing from becoming confused by client locales other than C.
Fixes Berlios tracker bug #17379: problem with different locale.
Diffstat (limited to 'json.c')
-rw-r--r-- | json.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -56,6 +56,7 @@ PERMISSIONS #include <string.h> #include <stdlib.h> #include <stdarg.h> +#include <locale.h> #include "gpsd_config.h" /* for strlcpy() prototype */ #include "json.h" @@ -555,8 +556,14 @@ int json_read_array(const char *cp, const struct json_array_t *arr, int json_read_object(const char *cp, const struct json_attr_t *attrs, /*@null@*/ const char **end) { + char *savedlocale = setlocale(LC_ALL, NULL); + int st; + + setlocale(LC_ALL, "C"); json_debug_trace((1, "json_read_object() sees '%s'\n", cp)); - return json_internal_read_object(cp, attrs, NULL, 0, end); + st = json_internal_read_object(cp, attrs, NULL, 0, end); + setlocale(LC_ALL, savedlocale); + return st; } const /*@observer@*/ char *json_error_string(int err) |