Mailing List Archive

[master] df9bc1860 Make WS_Allocated() assert that pointers are not in the free part of WS
commit df9bc1860ff4d4c659aca71ec9ebcd4bdd0d31f1
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Wed Nov 30 08:47:25 2022 +0000

Make WS_Allocated() assert that pointers are not in the free part of WS

diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index d327ad757..d6ff67370 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -71,6 +71,7 @@ WS_Allocated(const struct ws *ws, const void *ptr, ssize_t len)
WS_Assert(ws);
if (len < 0)
len = strlen(p) + 1;
+ assert(!(p > ws->f && p <= ws->e));
return (p >= ws->s && (p + len) <= ws->f);
}

_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Re: [master] df9bc1860 Make WS_Allocated() assert that pointers are not in the free part of WS [ In reply to ]
On Wed, Nov 30, 2022 at 8:48 AM Poul-Henning Kamp <phk@freebsd.org> wrote:
>
>
> commit df9bc1860ff4d4c659aca71ec9ebcd4bdd0d31f1
> Author: Poul-Henning Kamp <phk@FreeBSD.org>
> Date: Wed Nov 30 08:47:25 2022 +0000
>
> Make WS_Allocated() assert that pointers are not in the free part of WS
>
> diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
> index d327ad757..d6ff67370 100644
> --- a/bin/varnishd/cache/cache_ws.c
> +++ b/bin/varnishd/cache/cache_ws.c
> @@ -71,6 +71,7 @@ WS_Allocated(const struct ws *ws, const void *ptr, ssize_t len)
> WS_Assert(ws);
> if (len < 0)
> len = strlen(p) + 1;
> + assert(!(p > ws->f && p <= ws->e));
> return (p >= ws->s && (p + len) <= ws->f);
> }

Just in case you were wondering, the workspace emulator already guarantees this.

Cheers,
Dridi
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Re: [master] df9bc1860 Make WS_Allocated() assert that pointers are not in the free part of WS [ In reply to ]
--------
Dridi Boukelmoune writes:

> > + assert(!(p > ws->f && p <= ws->e));
> > return (p >= ws->s && (p + len) <= ws->f);
> > }
>
> Just in case you were wondering, the workspace emulator already guarantees this.

yes, but I see no reason to not enforce it in production too.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@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.
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
Re: [master] df9bc1860 Make WS_Allocated() assert that pointers are not in the free part of WS [ In reply to ]
On Wed, Nov 30, 2022 at 9:41 AM Poul-Henning Kamp <phk@phk.freebsd.dk> wrote:
>
> --------
> Dridi Boukelmoune writes:
>
> > > + assert(!(p > ws->f && p <= ws->e));
> > > return (p >= ws->s && (p + len) <= ws->f);
> > > }
> >
> > Just in case you were wondering, the workspace emulator already guarantees this.
>
> yes, but I see no reason to not enforce it in production too.

I was not disagreeing with the change.

Cheers,
Dridi
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit