]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
JSON: Fix escaping of characters that have MSB=1 with signed char
authorJouni Malinen <j@w1.fi>
Sun, 27 Oct 2019 15:08:31 +0000 (17:08 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 27 Oct 2019 17:50:22 +0000 (19:50 +0200)
The "\\u%04x" printf string did not really work in the correct way if
char is signed. Fix this by type casting this to unsigned char.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/json.c

index b64433959ff7ba9dcfbee5e1732a1de8a32c3a44..3e5e2147722388340bf3d6287aeeaf0fc2652359 100644 (file)
@@ -51,7 +51,7 @@ void json_escape_string(char *txt, size_t maxlen, const char *data, size_t len)
                                *txt++ = data[i];
                        } else {
                                txt += os_snprintf(txt, end - txt, "\\u%04x",
-                                                  data[i]);
+                                                  (unsigned char) data[i]);
                        }
                        break;
                }