From: Henrik Nordstrom Date: Thu, 19 Feb 2009 09:36:01 +0000 (+0100) Subject: Correct parsing of syslog:... log files. Was destroying the configured parameters. X-Git-Tag: SQUID_3_2_0_1~1184 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ee2bd3892b062f8f4f791af7500d59e574bc711;p=thirdparty%2Fsquid.git Correct parsing of syslog:... log files. Was destroying the configured parameters. Forward-port from squid-2. Detected by GCC-4.4. --- diff --git a/src/logfile.cc b/src/logfile.cc index 0da0a31115..683ea19ce5 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -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; }