Terminate destination buffer in mg_url_decode

This commit is contained in:
robert committed 2026-09-01 17:33:56 +03:00
1 parent 9123330f72
commit 9ddac8faa7
3 files changed
+32 -10

No files matched your search

+4
View File
@@ -156,6 +156,10 @@ static void test_http_get_var(void) {
body = mg_str("key=broken%2x");
ASSERT(mg_http_get_var(&body, "key", buf, sizeof(buf)) == -3);
memset(buf, 'x', sizeof(buf));
body = mg_str("access_token=a%zz");
ASSERT(mg_http_get_var(&body, "access_token", buf, sizeof(buf)) == -3);
ASSERT(memchr(buf, '\0', sizeof(buf)) != NULL);
ASSERT(mg_http_get_var(&body, "inexistent", buf, sizeof(buf)) == -4);
body = mg_str("key=%");
ASSERT(mg_http_get_var(&body, "key", buf, sizeof(buf)) == -3);