Skip to content

Commit

Permalink
Check VRT_StrandsWS() return value
Browse files Browse the repository at this point in the history
Fixes: VSV00006
  • Loading branch information
nigoroll authored and mbgrydeland committed Mar 16, 2021
1 parent 350be1c commit 71a1f13
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ VMOD_TESTS = \
tests/bodyaccess/test04.vtc \
tests/bodyaccess/test05.vtc \
tests/header/append.vtc \
tests/header/append_maxhdr_overflow.vtc \
tests/header/append_overflow.vtc \
tests/header/copy.vtc \
tests/header/get.vtc \
tests/header/import.vtc \
Expand Down
45 changes: 45 additions & 0 deletions src/tests/header/append_maxhdr_overflow.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
varnishtest "header.append with http_max_hdr and overflow"

varnish v1 -arg "-p http_max_hdr=32" -vcl {
backend proforma None;

import vtc;
import std;
import header from "${vmod_builddir}/.libs/libvmod_header.so";

sub vcl_recv {
std.log(vtc.workspace_free(client));
header.append(req.http.foo, "bar");
}
} -start

client c1 {
txreq \
-hdr "0: 1" \
-hdr "1: 1" \
-hdr "2: 1" \
-hdr "3: 1" \
-hdr "4: 1" \
-hdr "5: 1" \
-hdr "6: 1" \
-hdr "7: 1" \
-hdr "8: 1" \
-hdr "9: 1" \
-hdr "a: 1" \
-hdr "b: 1" \
-hdr "c: 1" \
-hdr "d: 1" \
-hdr "e: 1" \
-hdr "f: 1" \
-hdr "10: 1" \
-hdr "11: 1" \
-hdr "12: 1" \
-hdr "13: 1" \
-hdr "14: 1" \
-hdr "15: 1" \
-hdr "16: 1" \
-hdr "17: 1" \
-hdr "18: 1" \
-hdr "19: 1"
rxresp
} -run
18 changes: 18 additions & 0 deletions src/tests/header/append_overflow.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
varnishtest "header.append overflow"

varnish v1 -vcl {
backend proforma None;

import vtc;
import header from "${vmod_builddir}/.libs/libvmod_header.so";

sub vcl_recv {
vtc.workspace_alloc(client, -2);
header.append(req.http.foo, "bar");
}
} -start

client c1 {
txreq
rxresp
} -run
4 changes: 4 additions & 0 deletions src/vmod_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ vmod_append(VRT_CTX, VCL_HEADER hdr, VCL_STRANDS s)
st->p = p;

b = VRT_StrandsWS(ctx->ws, NULL, st);
if (b == NULL) {
VRT_fail(ctx, "vmod_header: workspace allocation failure");
return;
}

hp = VRT_selecthttp(ctx, hdr->where);
http_SetHeader(hp, b);
Expand Down

0 comments on commit 71a1f13

Please sign in to comment.