]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
RFC 1123: Fix date parsing (#1538)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 25 Oct 2023 19:41:45 +0000 (19:41 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 25 Oct 2023 22:18:33 +0000 (22:18 +0000)
The bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/datetime-overflow.html
where it was filed as "1-Byte Buffer OverRead in RFC 1123 date/time
Handling".

src/time/rfc1123.cc

index 5496fe98578da85f1865051c65d360fc23707500..dfda9f723caf055e54c6afb8b24b531a7bdb4c38 100644 (file)
@@ -44,7 +44,13 @@ make_month(const char *s)
     char month[3];
 
     month[0] = xtoupper(*s);
+    if (!month[0])
+        return -1; // protects *(s + 1) below
+
     month[1] = xtolower(*(s + 1));
+    if (!month[1])
+        return -1; // protects *(s + 2) below
+
     month[2] = xtolower(*(s + 2));
 
     for (i = 0; i < 12; i++)