]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Honor 0x and 0 prefixes as numeric base indication when parsing squid.conf
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Apr 2008 04:41:41 +0000 (22:41 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Apr 2008 04:41:41 +0000 (22:41 -0600)
integer options.

Squid3 parses squid.conf file integers as decimal numbers while Squid2 honors
0 and 0x prefixes (indicating octal and hex numbers). The later functionality
is needed for things like unmask that are traditionally specified using octal
format.

This patch changes Squid3 behavior to match that of Squid2.
Internally, Squid3 uses sscanf and Squid2 uses strtol.

TODO: Squid3::GetInteger should probably use xatol,
and xatol should be fixed to proper verify the result of strtol.

src/Parsing.cc

index d2b08ba03ce82dd317bcf6b24e5af351a3c582ac..8915755d8bc2ad206514e57c5b464e7324d495ef 100644 (file)
@@ -89,7 +89,8 @@ GetInteger(void)
     if (token == NULL)
         self_destruct();
 
-    if (sscanf(token, "%d", &i) != 1)
+    // %i honors 0 and 0x prefixes, which are important for things like umask
+    if (sscanf(token, "%i", &i) != 1)
         self_destruct();
 
     return i;