[master] 1d23a7335 Correct WS allocation in tlv_string

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Nov 14 23:07:39 UTC 2019


--------

I thought the whole point was to *not* cause VRT_fail in *that* function ?

In message <20191114104906.608B6ADC27 at lists.varnish-cache.org>, Dridi Boukelmoune writes:
>
>commit 1d23a7335eda7741574e9b680401f5acc2a4d67d
>Author: Emmanuel Hocdet <manu at gandi.net>
>Date:   Thu Nov 14 11:14:07 2019 +0100
>
>    Correct WS allocation in tlv_string
>    
>    Fixes #3131
>
>diff --git a/lib/libvmod_proxy/vmod_proxy.c b/lib/libvmod_proxy/vmod_proxy.c
>index 58f2db295..222de9c53 100644
>--- a/lib/libvmod_proxy/vmod_proxy.c
>+++ b/lib/libvmod_proxy/vmod_proxy.c
>@@ -105,12 +105,13 @@ tlv_string(VRT_CTX, int tlv)
> 
> 	if (VPX_tlv(ctx->req, tlv, (void **)&dst, &len))
> 		return (NULL);
>-	if (!WS_ReserveSize(ctx->ws, len+1))
>+	d = WS_Alloc(ctx->ws, len+1);
>+	if (d == NULL) {
>+		VRT_fail(ctx, "proxy.TLV: out of workspace");
> 		return (NULL);
>-	d = ctx->ws->f;
>+	}
> 	memcpy(d, dst, len);
> 	d[len] = '\0';
>-	WS_Release(ctx->ws, len+1);
> 	return (d);
> }
> 
>_______________________________________________
>varnish-commit mailing list
>varnish-commit at varnish-cache.org
>https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
>

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the varnish-commit mailing list