diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-30 13:20:58 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-30 13:20:58 +0000 |
commit | 2dd6d08b5d4ec053095d532dc1540f6630553c9b (patch) | |
tree | d5f097c683603346f3dddcc62a08b2462307019a | |
parent | f8ab81bbb46f6ac1e2a27178356f6122cf90ec07 (diff) | |
download | rsyslog-2dd6d08b5d4ec053095d532dc1540f6630553c9b.tar.gz rsyslog-2dd6d08b5d4ec053095d532dc1540f6630553c9b.tar.xz rsyslog-2dd6d08b5d4ec053095d532dc1540f6630553c9b.zip |
- fixed a bug that could cause invalid string handling via strerror_r
varmojfekoj provided the patch - many thanks!
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | net.c | 2 | ||||
-rw-r--r-- | omfwd.c | 2 | ||||
-rw-r--r-- | rfc3195d.c | 6 | ||||
-rw-r--r-- | syslogd.c | 22 | ||||
-rw-r--r-- | syslogd.h | 1 | ||||
-rw-r--r-- | tcpsyslog.c | 4 |
8 files changed, 32 insertions, 12 deletions
@@ -1,4 +1,8 @@ --------------------------------------------------------------------------- +Version 2.0.2 STABLE (rgerhards), 2008-02-?? +- fixed a bug that could cause invalid string handling via strerror_r + varmojfekoj provided the patch - many thanks! +--------------------------------------------------------------------------- Version 2.0.1 STABLE (rgerhards), 2008-01-24 - fixed a bug in integer conversion - but this function was never called, so it is not really a useful bug fix ;) diff --git a/configure.ac b/configure.ac index c2fd803b..6ca8bb41 100644 --- a/configure.ac +++ b/configure.ac @@ -81,9 +81,10 @@ AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_TYPE_SIGNAL AC_FUNC_STAT +AC_FUNC_STRERROR_R AC_FUNC_VPRINTF AC_FUNC_WAIT3 -AC_CHECK_FUNCS([alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strerror_r strndup strnlen strrchr strstr strtol strtoul uname ttyname_r]) +AC_CHECK_FUNCS([alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r]) # Large file support @@ -66,7 +66,7 @@ int should_use_so_bsdcompat(void) init_done = 1; if (uname(&utsname) < 0) { char errStr[1024]; - dbgprintf("uname: %s\r\n", strerror_r(errno, errStr, sizeof(errStr))); + dbgprintf("uname: %s\r\n", rs_strerror_r(errno, errStr, sizeof(errStr))); return 1; } /* Format is <version>.<patchlevel>.<sublevel><extraversion> @@ -441,7 +441,7 @@ CODESTARTdoAction int eno = errno; char errStr[1024]; dbgprintf("sendto() error: %d = %s.\n", - eno, strerror_r(eno, errStr, sizeof(errStr))); + eno, rs_strerror_r(eno, errStr, sizeof(errStr))); } } if (lsent == l && !send_to_all) @@ -96,7 +96,7 @@ static void openlog() if(LogFile < 0) { char errStr[1024]; printf("error opening '%s': %s\n", - pPathLogname, strerror_r(errno, errStr, sizeof(errStr))); + pPathLogname, rs_strerror_r(errno, errStr, sizeof(errStr))); } } if (LogFile != -1 && !connected && @@ -106,7 +106,7 @@ static void openlog() else { char errStr[1024]; printf("error connecting '%s': %s\n", - pPathLogname, strerror_r(errno, errStr, sizeof(errStr))); + pPathLogname, rs_strerror_r(errno, errStr, sizeof(errStr))); } } @@ -162,7 +162,7 @@ void OnReceive(srAPIObj* pAPI, srSLMGObj* pSLMG) if(nWritten < 0) { /* error, recover! */ char errStr[1024]; - printf("error writing to domain socket: %s\r\n", strerror_r(errno, errStr, sizeof(errStr))); + printf("error writing to domain socket: %s\r\n", rs_strerror_r(errno, errStr, sizeof(errStr))); closelog(); } else { /* prepare for (potential) next write */ @@ -3563,7 +3563,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... */ @@ -4349,7 +4349,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); } @@ -5466,6 +5466,20 @@ void dbgprintf(char *fmt, ...) } +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 @@ -5727,7 +5741,7 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se printchopped(LocalHostName, line, iRcvd, fd, funixParseHost[i]); } else if (iRcvd < 0 && errno != EINTR) { char errStr[1024]; - strerror_r(errno, errStr, sizeof(errStr)); + rs_strerror_r(errno, errStr, sizeof(errStr)); dbgprintf("UNIX socket error: %d = %s.\n", \ errno, errStr); logerror("recvfrom UNIX"); @@ -5768,7 +5782,7 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se } } else if (l < 0 && errno != EINTR && errno != EAGAIN) { char errStr[1024]; - strerror_r(errno, errStr, sizeof(errStr)); + rs_strerror_r(errno, errStr, sizeof(errStr)); dbgprintf("INET socket error: %d = %s.\n", errno, errStr); logerror("recvfrom inet"); /* should be harmless */ @@ -48,6 +48,7 @@ #define MARK 0x008 /* this message is a mark */ void dbgprintf(char *, ...); +char *rs_strerror_r(int errnum, char *buf, size_t buflen); void logerror(char *type); void logerrorSz(char *type, char *errMsg); void logerrorInt(char *type, int iErr); diff --git a/tcpsyslog.c b/tcpsyslog.c index c7693102..311e4308 100644 --- a/tcpsyslog.c +++ b/tcpsyslog.c @@ -1021,7 +1021,7 @@ int TCPSendCreateSocket(struct addrinfo *addrDest) } else { char errStr[1024]; dbgprintf("create tcp connection failed, reason %s", - strerror_r(errno, errStr, sizeof(errStr))); + rs_strerror_r(errno, errStr, sizeof(errStr))); } } @@ -1032,7 +1032,7 @@ int TCPSendCreateSocket(struct addrinfo *addrDest) } else { char errStr[1024]; - dbgprintf("couldn't create send socket, reason %s", strerror_r(errno, errStr, sizeof(errStr))); + dbgprintf("couldn't create send socket, reason %s", rs_strerror_r(errno, errStr, sizeof(errStr))); } r = r->ai_next; } |