From a39d92d6d2e4e42996ae146ef04f1d27e8dab39f Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 8 Feb 2013 23:42:44 -0700 Subject: [PATCH] Fix parsing of max-stale values in Surrogate-Control header Skip parsing of the max-stale field when the initial max-age value is not a valid integer value. Detected by Coverity Scan. Issue 740361 --- src/HttpHdrSc.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/HttpHdrSc.cc b/src/HttpHdrSc.cc index 34e94f3bb3..05162e1c1c 100644 --- a/src/HttpHdrSc.cc +++ b/src/HttpHdrSc.cc @@ -196,22 +196,23 @@ HttpHdrSc::parse(const String * str) int ma; if (p && httpHeaderParseInt(p, &ma)) { sct->maxAge(ma); + + if ((p = strchr (p, '+'))) { + int ms; + ++p; //skip the + char + if (httpHeaderParseInt(p, &ms)) { + sct->maxStale(ms); + } else { + debugs(90, 2, "sc: invalid max-stale specs near '" << item << "'"); + sct->clearMaxStale(); + /* leave the max-age alone */ + } + } } else { debugs(90, 2, "sc: invalid max-age specs near '" << item << "'"); sct->clearMaxAge(); } - if ((p = strchr (p, '+'))) { - int ms; - ++p; //skip the + char - if (httpHeaderParseInt(p, &ms)) { - sct->maxStale(ms); - } else { - debugs(90, 2, "sc: invalid max-stale specs near '" << item << "'"); - sct->clearMaxStale(); - /* leave the max-age alone */ - } - } break; } -- 2.47.2