]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Check invariant on HttpHeader.cc:headerTable at startup
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 13:06:23 +0000 (15:06 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 30 Jul 2015 13:06:23 +0000 (15:06 +0200)
src/HttpHeader.cc

index ee32647d53f0a4965b9ab59e06ffa8b675af2491..f36412d8d1b2dd06273f243cdcfa6535f2ab55e6 100644 (file)
@@ -175,6 +175,7 @@ static const HeaderTableRecord headerTable[] = {
     {"Age", HDR_AGE, ftInt},
     {"Allow", HDR_ALLOW, ftStr},
     {"Alternate-Protocol", HDR_ALTERNATE_PROTOCOL, ftStr},
+    {"Authentication-Info", HDR_AUTHENTICATION_INFO, ftStr},
     {"Authorization", HDR_AUTHORIZATION, ftStr},    /* for now */
     {"Cache-Control", HDR_CACHE_CONTROL, ftPCc},
     {"Connection", HDR_CONNECTION, ftStr},
@@ -237,7 +238,6 @@ static const HeaderTableRecord headerTable[] = {
     {"Via", HDR_VIA, ftStr},    /* for now */
     {"Warning", HDR_WARNING, ftStr},    /* for now */
     {"WWW-Authenticate", HDR_WWW_AUTHENTICATE, ftStr},
-    {"Authentication-Info", HDR_AUTHENTICATION_INFO, ftStr},
     {"X-Cache", HDR_X_CACHE, ftStr},
     {"X-Cache-Lookup", HDR_X_CACHE_LOOKUP, ftStr},
     {"X-Forwarded-For", HDR_X_FORWARDED_FOR, ftStr},
@@ -478,6 +478,11 @@ httpHeaderInitModule(void)
 
     if (!Headers)
         Headers = httpHeaderBuildFieldsInfo(HeadersAttrs, HDR_ENUM_END);
+
+    // check invariant: for each index in headerTable, (int)headerTable[index] = index
+    for (int i = 0; headerTable[i].name; ++i)
+        assert(headerTable[i].id == i);
+
     // use headerLookupTable in place of Headers
 
     /* create masks */