diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-06-21 19:19:37 +0400 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-06-21 19:19:37 +0400 |
commit | 6f192a6fb04504e065c222be11a6e294229300fe (patch) | |
tree | ab7c51e234b36b836866b5c4253735f43fe30033 /blobmsg_json.c | |
parent | 7c5d2b30815b5ff0b6bce35c1e486b3c17cce55b (diff) |
blobmsg_json: do not corrupt UTF-8 strings
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'blobmsg_json.c')
-rw-r--r-- | blobmsg_json.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/blobmsg_json.c b/blobmsg_json.c index 7e6fca4..9835a88 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -151,11 +151,12 @@ static void add_separator(struct strbuf *s) static void blobmsg_format_string(struct strbuf *s, const char *str) { - const char *p, *last = str, *end = str + strlen(str); + const unsigned char *p, *last, *end; char buf[8] = "\\u00"; + end = (unsigned char *) str + strlen(str); blobmsg_puts(s, "\"", 1); - for (p = str; *p; p++) { + for (p = (unsigned char *) str, last = p; *p; p++) { char escape = '\0'; int len; @@ -187,7 +188,7 @@ static void blobmsg_format_string(struct strbuf *s, const char *str) continue; if (p > last) - blobmsg_puts(s, last, p - last); + blobmsg_puts(s, (char *) last, p - last); last = p + 1; buf[1] = escape; @@ -200,7 +201,7 @@ static void blobmsg_format_string(struct strbuf *s, const char *str) blobmsg_puts(s, buf, len); } - blobmsg_puts(s, last, end - last); + blobmsg_puts(s, (char *) last, end - last); blobmsg_puts(s, "\"", 1); } |