summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-17 09:43:20 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-17 09:43:20 -0500
commit904b568b169b8f21c3b380bc3a98b0f79f80c7db (patch)
treed55569ac132290faf8f1fe2cbefe436d668453d4 /json.c
parent1fadd3a923fa3a181ca00c23f7f7171f3ebd0488 (diff)
downloadgpsd-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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/json.c b/json.c
index 27f39a28..9b441dd7 100644
--- a/json.c
+++ b/json.c
@@ -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)