Mailing List Archive

[7.1] 0fb3baff7 Clean up assertions in http_hdr_flags()
commit 0fb3baff7963604a55be0ed6ebdf1e4654ead219
Author: Martin Blix Grydeland <martin@varnish-software.com>
Date: Thu Aug 4 11:04:37 2022 +0200

Clean up assertions in http_hdr_flags()

The input argument assertions and checks in http_hdr_flags() were
misleading and lacking. With this patch it returns (NULL) on either input
being NULL, and also when called with an empty string instead of
asserting.

diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 3f5ee0384..194055c3c 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -140,9 +140,9 @@ http_hdr_flags(const char *b, const char *e)
unsigned u;
struct http_hdrflg *retval;

- if (e == NULL)
- return(NULL);
- assert(e > b);
+ if (b == NULL || e == NULL)
+ return (NULL);
+ assert(b <= e);
u = (unsigned)(e - b);
assert(b + u == e);
if (u < 2 || u > 19) // MIN_WORD_LENGTH & MAX_WORD_LENGTH
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit