]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 3 Apr 2009 21:05:19 +0000 (10:05 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 3 Apr 2009 21:05:19 +0000 (10:05 +1300)
Correct parsing of syslog:... log files. Was destroying the configured parameters.

Forward-port from squid-2. Detected by GCC-4.4.

src/logfile.cc

index 7762c56ef0023c5de0cfa0b324bbabb6cca6010e..0160f0a720357829c37cbd03f3155eea85127d8a 100644 (file)
@@ -102,19 +102,16 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
 
         if (path[6] != '\0') {
             path += 7;
-            char* delim = strchr(path, '.');
-
-           if (!delim)
-               delim = strchr(path, '|');
-
-            if (delim != NULL)
-                *delim = '\0';
-
-            lf->syslog_priority = syslog_ntoa(path);
-
-            if (delim != NULL)
-                lf->syslog_priority |= syslog_ntoa(delim+1);
-
+           char *priority = xstrdup(path);
+           char *facility = (char *) strchr(priority, '.');
+           if (!facility)
+               facility = (char *) strchr(priority, '|');
+           if (facility) {
+               *facility++ = '\0';
+               lf->syslog_priority |= syslog_ntoa(facility);
+           }
+           lf->syslog_priority |= syslog_ntoa(priority);
+           xfree(priority);
             if (0 == (lf->syslog_priority & PRIORITY_MASK))
                 lf->syslog_priority |= LOG_INFO;
         }