]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Correct parsing of syslog:... log files. Was destroying the configured parameters.
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Thu, 19 Feb 2009 09:36:01 +0000 (10:36 +0100)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Thu, 19 Feb 2009 09:36:01 +0000 (10:36 +0100)
Forward-port from squid-2. Detected by GCC-4.4.

src/logfile.cc

index 0da0a31115ac3c066539a6be9315fef5dd0c89e0..683ea19ce5096ffe9f0e602f3efc38436a8c0f46 100644 (file)
@@ -101,19 +101,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;
         }