From 6da64a47beff44ecdb45c82b033811f2d19819af Mon Sep 17 00:00:00 2001 From: Martin Blix Grydeland Date: Fri, 23 Aug 2019 13:53:42 +0200 Subject: [PATCH] Avoid some code duplication Apply some adjustments to recent patches based off of review by Nils Goroll at UPLEX (@nigoroll) --- bin/varnishd/http1/cache_http1_proto.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 61563b8ead..31c75ed88d 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -128,15 +128,16 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc, r++; continue; } - if (!vct_iscrlf(r, htc->rxbuf_e)) { + i = vct_iscrlf(r, htc->rxbuf_e); + if (i == 0) { VSLb(hp->vsl, SLT_BogoHeader, "Header has ctrl char 0x%02x", *r); return (400); } q = r; - assert(r < htc->rxbuf_e); - r = vct_skipcrlf(r, htc->rxbuf_e); - if (r >= htc->rxbuf_e) + r += i; + assert(r <= htc->rxbuf_e); + if (r == htc->rxbuf_e) break; if (vct_iscrlf(r, htc->rxbuf_e)) break;