diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-30 13:33:17 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-30 13:33:17 +0000 |
commit | 57cf2138522f3dacf26ea30c6f32a800def70209 (patch) | |
tree | 226dcea739dca9fd268fac31afecbcab229b8831 /syslogd.c | |
parent | 61b10104612b3d776399f853f399e64ffe175e65 (diff) | |
download | rsyslog-57cf2138522f3dacf26ea30c6f32a800def70209.tar.gz rsyslog-57cf2138522f3dacf26ea30c6f32a800def70209.tar.bz2 rsyslog-57cf2138522f3dacf26ea30c6f32a800def70209.zip |
fixed a bug that could cause invalid string handling via strerror_r
varmojfekoj provided the patch - many thanks!
Diffstat (limited to 'syslogd.c')
-rw-r--r-- | syslogd.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -2341,7 +2341,7 @@ void logerror(char *type) if (errno == 0) snprintf(buf, sizeof(buf), "%s", type); else { - strerror_r(errno, errStr, sizeof(errStr)); + rs_strerror_r(errno, errStr, sizeof(errStr)); snprintf(buf, sizeof(buf), "%s: %s", type, errStr); } buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */ @@ -3045,7 +3045,7 @@ finalize_it: if(fCurr != NULL) selectorDestruct(fCurr); - strerror_r(errno, errStr, sizeof(errStr)); + rs_strerror_r(errno, errStr, sizeof(errStr)); dbgprintf("error %d processing config file '%s'; os error (if any): %s\n", iRet, pConfFile, errStr); } @@ -4133,6 +4133,20 @@ int decode(uchar *name, struct code *codetab) +char *rs_strerror_r(int errnum, char *buf, size_t buflen) { +#ifdef STRERROR_R_CHAR_P + char *p = strerror_r(errnum, buf, buflen); + if (p != buf) { + strncpy(buf, p, buflen); + buf[buflen - 1] = '\0'; + } +#else + strerror_r(errnum, buf, buflen); +#endif + return buf; +} + + /* * The following function is resposible for handling a SIGHUP signal. Since * we are now doing mallocs/free as part of init we had better not being |