[master] 3056e30aa Clean up assertions in http_hdr_flags()
    Martin Blix Grydeland 
    martin at varnish-software.com
       
    Tue Aug  9 08:55:06 UTC 2022
    
    
  
commit 3056e30aa4879653d2697167440b21f125b9fa7e
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 d48c0bb36..6c9f1da6c 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -145,9 +145,9 @@ http_hdr_flags(const char *b, const char *e)
 	unsigned u;
 	struct http_hdrflg *retval;
 
-	if (e == NULL)
+	if (b == NULL || e == NULL)
 		return (NULL);
-	assert(e > b);
+	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