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

Commit 1efe2b3

Browse files
committed
Don't shift a signed char like that.
1 parent 2a00b3e commit 1efe2b3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/tests/urlcode01.vtc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ server s1 {
99
-hdr "Foo5: %2" \
1010
-hdr "Foo6: %" \
1111
-hdr "Foo7: +" \
12+
-hdr "Foo8: \xf6\xff" \
1213
-hdr "Connection: close" \
1314
-body "Hi!\n"
1415
} -start
@@ -34,6 +35,7 @@ varnish v1 -vcl+backend {
3435
set beresp.http.Baz6 = urlcode.decode({"hello%20"}
3536
+ beresp.http.nonexistant + "world") + "!";
3637
set beresp.http.Baz7 = urlcode.decode(beresp.http.nonexistant) + "!";
38+
set beresp.http.Bar8 = urlcode.encode(beresp.http.Foo8);
3739
}
3840
} -start
3941

@@ -55,4 +57,5 @@ client c1 {
5557
expect resp.http.bar6 == "hello%20world!"
5658
expect resp.http.baz6 == "hello world!"
5759
expect resp.http.baz7 == "!"
60+
expect resp.http.bar8 == "%F6%FF"
5861
} -run

src/vmod_urlcode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ vmod_encode(struct sess *sp, const char *str, ...)
3434
b = e; /* not enough space */
3535
} else {
3636
*b++ = '%';
37-
*b++ = hexchars[*str >> 4];
37+
unsigned char foo = *str;
38+
*b++ = hexchars[foo >> 4];
3839
*b++ = hexchars[*str & 15];
3940
str++;
4041
}

0 commit comments

Comments
 (0)