mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-02 13:20:51 +00:00
fix(json): reject malformed hex input
Reject odd-length and non-hex strings before decoding them. Tested: 1796 ASan/UBSan tests in amalgamated and unamalgamated builds
This commit is contained in:
1 parent
bc69625a5e
commit
dc52d8b1dc
5 files changed
+29
-13
No files matched your search
+1
-1
@@ -57,7 +57,7 @@ char *mg_json_get_str(struct mg_str json, const char *path);
|
||||
|
||||
// Decodes a hex-encoded JSON string at path into a heap-allocated byte array.
|
||||
// Sets *len to the decoded byte count. Caller must mg_free() the result.
|
||||
// Returns NULL if not found or not a string.
|
||||
// Returns NULL if not found, not a string, or not valid hexadecimal.
|
||||
char *mg_json_get_hex(struct mg_str json, const char *path, int *len);
|
||||
|
||||
// Decodes a base64-encoded JSON string at path into a heap-allocated byte
|
||||
|
||||
Reference in new issue
Block a user