Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 2a00b3e

Browse files
committed
Don't segfault on trailing NULL
1 parent 956a277 commit 2a00b3e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/tests/urlcode01.vtc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ varnish v1 -vcl+backend {
3333
+ beresp.http.nonexistant + "world") + "!";
3434
set beresp.http.Baz6 = urlcode.decode({"hello%20"}
3535
+ beresp.http.nonexistant + "world") + "!";
36+
set beresp.http.Baz7 = urlcode.decode(beresp.http.nonexistant) + "!";
3637
}
3738
} -start
3839

@@ -53,4 +54,5 @@ client c1 {
5354
expect resp.http.baz5 == "hello world!"
5455
expect resp.http.bar6 == "hello%20world!"
5556
expect resp.http.baz6 == "hello world!"
57+
expect resp.http.baz7 == "!"
5658
} -run

src/vmod_urlcode.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ vmod_encode(struct sess *sp, const char *str, ...)
2626
e += u;
2727
va_start(ap, str);
2828
while (b < e && str != vrt_magic_string_end) {
29-
while (str == NULL)
30-
str = va_arg(ap, const char *);
31-
while (b < e && *str) {
29+
while (b < e && str && *str) {
3230
if (visalnum((int) *str) || *str == '-' || *str == '.'
3331
|| *str == '_' || *str == '~') { /* RFC3986 2.3 */
3432
*b++ = *str++;

0 commit comments

Comments
 (0)