[7.0] 6c784d0b3 Clean up assertions in http_hdr_flags()
Martin Blix Grydeland
martin at varnish-software.com
Tue Aug 9 08:57:05 UTC 2022
commit 6c784d0b331d771030bcd1cd331fe6632982c784
Author: Martin Blix Grydeland <martin at 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 b4eaf911c..1d0a87811 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
More information about the varnish-commit
mailing list