From d844f2b9ff50cfa7bf7f5b445d9f7eed7e6c3015 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 25 May 2020 08:31:08 +0200 Subject: altsvc: fix parser for lines ending with CRLF Fixed the alt-svc parser to treat a newline as end of line. The unit tests in test 1654 were done without CRLF and thus didn't quite match the real world. Now they use CRLF as well. Reported-by: Peter Wu Assisted-by: Peter Wu Assisted-by: Jay Satiro Fixes #5445 Closes #5446 --- lib/altsvc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/altsvc.c b/lib/altsvc.c index f6c5c0612..bb72a33a4 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -431,6 +431,8 @@ static time_t debugtime(void *unused) #define time(x) debugtime(x) #endif +#define ISNEWLINE(x) (((x) == '\n') || (x) == '\r') + /* * Curl_altsvc_parse() takes an incoming alt-svc response header and stores * the data correctly in the cache. @@ -520,12 +522,12 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data, /* Handle the optional 'ma' and 'persist' flags. Unknown flags are skipped. */ for(;;) { - while(*p && ISBLANK(*p) && *p != ';' && *p != ',') + while(ISBLANK(*p)) p++; - if(!*p || *p == ',') + if(*p != ';') break; p++; /* pass the semicolon */ - if(!*p) + if(!*p || ISNEWLINE(*p)) break; result = getalnum(&p, option, sizeof(option)); if(result) { -- cgit v1.2.3