From: Amos Jeffries Date: Fri, 3 Apr 2009 21:05:19 +0000 (+1300) Subject: Author: Henrik Nordstrom X-Git-Tag: SQUID_3_0_STABLE14~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3490483d4e10c56facb060a00552b3c6aae9b2e;p=thirdparty%2Fsquid.git Author: Henrik Nordstrom 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 7762c56ef0..0160f0a720 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -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; }