[master] d7a0253ca v1f: Parse CRLF separately from other white space
Asad Sajjad Ahmed
asadsa at varnish-software.com
Mon May 12 12:57:06 UTC 2025
commit d7a0253ca1bbf3177e6c980c22b41602561592a5
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Apr 2 16:03:43 2025 +0200
v1f: Parse CRLF separately from other white space
It's a little bit harder to follow the CRLF logic when it is intertwined
with the skipped surrounding white space.
diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c
index d684f1043..fbc3dcb8b 100644
--- a/bin/varnishd/http1/cache_http1_vfp.c
+++ b/bin/varnishd/http1/cache_http1_vfp.c
@@ -132,7 +132,7 @@ v1f_chunked_hdr(struct vfp_ctx *vc, struct http_conn *htc, ssize_t *szp)
lr = v1f_read(vc, htc, buf, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
- } while (vct_islws(buf[0]));
+ } while (vct_isows(buf[0]));
if (!vct_ishex(buf[0]))
return (VFP_Error(vc, "chunked header non-hex"));
@@ -152,12 +152,14 @@ v1f_chunked_hdr(struct vfp_ctx *vc, struct http_conn *htc, ssize_t *szp)
return (VFP_Error(vc, "chunked header too long"));
/* Skip trailing white space */
- while (vct_islws(buf[u]) && buf[u] != '\n') {
+ while (vct_isows(buf[u])) {
lr = v1f_read(vc, htc, buf + u, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
}
+ if (buf[u] == '\r' && v1f_read(vc, htc, buf + u, 1) <= 0)
+ return (VFP_Error(vc, "chunked read err"));
if (buf[u] != '\n')
return (VFP_Error(vc, "chunked header no NL"));
More information about the varnish-commit
mailing list