Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect bug fixes for 7.3.1 #3922

Merged
merged 9 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/varnishd/cache/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ void VSLbs(struct vsl_log *, enum VSL_tag_e tag, const struct strands *s);
void VSLb_ts(struct vsl_log *, const char *event, vtim_real first,
vtim_real *pprev, vtim_real now);
void VSLb_bin(struct vsl_log *, enum VSL_tag_e, ssize_t, const void*);
int VSL_tag_is_masked(enum VSL_tag_e tag);

static inline void
VSLb_ts_req(struct req *req, const char *event, vtim_real now)
Expand Down
4 changes: 4 additions & 0 deletions bin/varnishd/cache/cache_backend_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,12 @@ VBP_Remove(struct backend *be)
be->probe = NULL;
vt->backend = NULL;
if (vt->running) {
// task scheduled, it calls vbp_delete()
vt->running = -1;
vt = NULL;
} else if (vt->heap_idx != VBH_NOIDX) {
// task done, not yet rescheduled
VBH_delete(vbp_heap, vt->heap_idx);
}
Lck_Unlock(&vbp_mtx);
if (vt != NULL) {
Expand Down
7 changes: 4 additions & 3 deletions bin/varnishd/cache/cache_esi_deliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
{
int i = 0;
const char *p;
uint16_t status;
struct ecx *ecx;
struct ved_foo foo[1];
struct vrt_ctx ctx[1];
Expand All @@ -869,9 +870,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (wantbody == 0)
return;

if (!ecx->incl_cont &&
req->resp->status != 200 &&
req->resp->status != 204) {
status = req->resp->status % 1000;

if (!ecx->incl_cont && status != 200 && status != 204) {
req->top->topreq->vdc->retval = -1;
req->top->topreq->doclose = req->doclose;
return;
Expand Down
6 changes: 6 additions & 0 deletions bin/varnishd/cache/cache_shmlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ vsl_tag_is_masked(enum VSL_tag_e tag)
return (*bm & b);
}

int
VSL_tag_is_masked(enum VSL_tag_e tag)
{
return (vsl_tag_is_masked(tag));
}

/*--------------------------------------------------------------------
* Lay down a header fields, and return pointer to the next record
*/
Expand Down
6 changes: 6 additions & 0 deletions bin/varnishd/cache/cache_vrt_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdio.h>

#include "cache_varnishd.h"
#include "cache_objhead.h"
#include "cache_transport.h"
#include "common/heritage.h"

Expand Down Expand Up @@ -595,6 +596,11 @@ VRT_u_bereq_body(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
if (ctx->bo->bereq_body != NULL) {
HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body, 0);
http_Unset(ctx->bo->bereq, H_Content_Length);
}

if (ctx->bo->req != NULL) {
CHECK_OBJ(ctx->bo->req, REQ_MAGIC);
ctx->bo->req = NULL;
Expand Down
7 changes: 3 additions & 4 deletions bin/varnishd/http2/cache_http2_hpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len)
n = HTTP_HDR_URL;
disallow_empty = 1;

// rfc7540,l,3060,3071
if (((len > 0 && *b != '/') ||
(len > 1 && *(b+1) == '/')) &&
(strncmp(b, "*", len) != 0)) {
// rfc9113,l,2693,2705
if (len > 0 && *b != '/' &&
strncmp(b, "*", len) != 0) {
VSLb(hp->vsl, SLT_BogoHeader,
"Illegal :path pseudo-header %.*s",
(int)len, b);
Expand Down
4 changes: 4 additions & 0 deletions bin/varnishd/http2/cache_http2_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len)
const char *p;
unsigned u;

if (VSL_tag_is_masked(SLT_H2RxHdr) &&
VSL_tag_is_masked(SLT_H2RxBody))
return;

AN(ptr);
assert(len >= 9);
b = ptr;
Expand Down
4 changes: 2 additions & 2 deletions bin/varnishtest/tests/a02027.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ client c1 {
client c1 {
stream 1 {
txreq -noadd -hdr ":authority" "foo.com" -hdr ":path" "//foo" -hdr ":scheme" "http" -hdr ":method" "GET"
rxrst
expect rst.err == PROTOCOL_ERROR
rxresp
expect resp.status == 200
} -run

} -run
Expand Down
29 changes: 20 additions & 9 deletions bin/varnishtest/tests/e00003.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ server s1 {
txresp -body {
<html>
Before include
<esi:include src="/body" sr="foo"/>
After include
<esi:include src="/body" sr="foo"/><esi:include src="/synth"/>After include
</html>
}
rxreq
Expand All @@ -21,9 +20,17 @@ server s1 {
} -start

varnish v1 -vcl+backend {
sub vcl_synth {
set resp.body = """
""";
return (deliver);
}
sub vcl_recv {
if (req.esi_level > 0) {
set req.url = req.url + req.esi_level;
if (req.url ~ "^/synth") {
return (synth(3200));
}
} else {
set req.http.esi0 = "foo";
}
Expand Down Expand Up @@ -64,7 +71,7 @@ logexpect l4 -v v1 -g request {
} -start

logexpect l5 -v v1 -g request {
expect * 1005 Begin "^req .* rxreq"
expect * 1006 Begin "^req .* rxreq"
# Header bytes is 5 larger than in l1 due to two item X-Varnish hdr
expect * = ReqAcct "^29 0 29 175 75 250$"
expect 0 = End
Expand All @@ -87,7 +94,7 @@ client c1 {
}

client c1 -run
varnish v1 -expect esi_req == 2
varnish v1 -expect esi_req == 4
varnish v1 -expect esi_errors == 0
varnish v1 -expect MAIN.s_resp_bodybytes == 150

Expand All @@ -104,7 +111,7 @@ shell {

cat >expected.txt <<-EOF
1001 c rxreq
1005 c rxreq
1006 c rxreq
EOF
diff -u expected.txt ncsa.txt
}
Expand All @@ -129,8 +136,10 @@ shell {
cat >expected.txt <<-EOF
1001 c rxreq
1003 c esi
1005 c rxreq
1006 c esi
1005 c esi
1006 c rxreq
1007 c esi
1008 c esi
EOF
diff -u expected.txt ncsa.txt
}
Expand All @@ -145,8 +154,10 @@ shell {
1002 b fetch
1003 c esi
1004 b fetch
1005 c rxreq
1006 c esi
1005 c esi
1006 c rxreq
1007 c esi
1008 c esi
EOF
diff -u expected.txt ncsa.txt
}
Expand Down
33 changes: 33 additions & 0 deletions bin/varnishtest/tests/v00068.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
varnishtest "unset bereq.body with cached req body"

server s1 {
rxreq
expect req.method == "GET"
expect req.http.Content-Length == <undef>
txresp

rxreq
expect req.method == "GET"
txresp
} -start

varnish v1 -vcl+backend {
import std;

sub vcl_recv {
std.cache_req_body(2KB);
}
sub vcl_backend_fetch {
unset bereq.body;
}
} -start

client c1 {
txreq -body "fine"
rxresp
expect resp.status == 200

txreq
rxresp
expect resp.status == 200
} -run
4 changes: 3 additions & 1 deletion bin/varnishtest/vtc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ uds_open(void *priv, const struct sockaddr_un *uds)
double *p;
int s, i, tmo;
struct pollfd fds[1];
socklen_t sl = sizeof(*uds);
socklen_t sl;

sl = VUS_socklen(uds);

AN(priv);
AN(uds);
Expand Down
1 change: 1 addition & 0 deletions include/vus.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int VUS_resolver(const char *path, vus_resolved_f *func, void *priv,
const char **err);
int VUS_bind(const struct sockaddr_un *uds, const char **errp);
int VUS_connect(const char *path, int msec);
unsigned int VUS_socklen(const struct sockaddr_un *uds);

static inline int
VUS_is(const char *path)
Expand Down
29 changes: 27 additions & 2 deletions lib/libvarnish/vus.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ VUS_resolver(const char *path, vus_resolved_f *func, void *priv,
if (ret)
return (ret);

assert(uds.sun_path[1] != '\0');

if (func != NULL)
ret = func(priv, &uds);
return (ret);
Expand All @@ -95,7 +97,9 @@ int
VUS_bind(const struct sockaddr_un *uds, const char **errp)
{
int sd, e;
socklen_t sl = sizeof(*uds);
socklen_t sl;

sl = VUS_socklen(uds);

if (errp != NULL)
*errp = NULL;
Expand Down Expand Up @@ -133,13 +137,18 @@ VUS_connect(const char *path, int msec)
int s, i;
struct pollfd fds[1];
struct sockaddr_un uds;
socklen_t sl = (socklen_t) sizeof(uds);
socklen_t sl;

if (path == NULL)
return (-1);
i = sun_init(&uds, path, NULL);
if (i)
return (i);

assert(uds.sun_path[1] != '\0');

sl = VUS_socklen(&uds);

AN(sl);

s = socket(PF_UNIX, SOCK_STREAM, 0);
Expand Down Expand Up @@ -182,3 +191,19 @@ VUS_connect(const char *path, int msec)

return (VTCP_connected(s));
}

socklen_t
VUS_socklen(const struct sockaddr_un *uds)
{
socklen_t sl;
const char *p;
if (*uds->sun_path)
sl = sizeof(*uds);
else {
p = strchr(uds->sun_path + 1, '\0');
assert(p != NULL);
sl = p - (const char*)uds;
}
assert(sl <= sizeof(*uds));
return sl;
}
3 changes: 3 additions & 0 deletions lib/libvgz/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,9 @@ local block_state deflate_stored(s, flush)
s->strm->total_out += len;
}
} while (last == 0);
if (last)
s->strm->stop_bit =
(s->strm->total_out + s->pending) * 8 + s->bi_valid;

/* Update the sliding window with the last s->w_size bytes of the copied
* data, or append all of the copied data to the existing window if less
Expand Down