strerror fix (#428775)

This commit is contained in:
Peter Vrabec 2008-01-22 12:41:58 +00:00
parent 4c5d31dfab
commit ee492f5340
2 changed files with 169 additions and 1 deletions

View File

@ -0,0 +1,162 @@
diff -up rsyslog-2.0.0/syslogd.c.strerror rsyslog-2.0.0/syslogd.c
--- rsyslog-2.0.0/syslogd.c.strerror 2008-01-22 11:59:58.000000000 +0100
+++ rsyslog-2.0.0/syslogd.c 2008-01-22 12:13:35.000000000 +0100
@@ -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 m
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 m
}
} 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 */
diff -up rsyslog-2.0.0/configure.ac.strerror rsyslog-2.0.0/configure.ac
--- rsyslog-2.0.0/configure.ac.strerror 2008-01-22 12:01:24.000000000 +0100
+++ rsyslog-2.0.0/configure.ac 2008-01-22 12:02:01.000000000 +0100
@@ -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
diff -up rsyslog-2.0.0/omfwd.c.strerror rsyslog-2.0.0/omfwd.c
--- rsyslog-2.0.0/omfwd.c.strerror 2008-01-22 11:58:38.000000000 +0100
+++ rsyslog-2.0.0/omfwd.c 2008-01-22 12:14:51.000000000 +0100
@@ -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)
diff -up rsyslog-2.0.0/rfc3195d.c.strerror rsyslog-2.0.0/rfc3195d.c
--- rsyslog-2.0.0/rfc3195d.c.strerror 2008-01-22 11:59:01.000000000 +0100
+++ rsyslog-2.0.0/rfc3195d.c 2008-01-22 12:15:14.000000000 +0100
@@ -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
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 */
diff -up rsyslog-2.0.0/net.c.strerror rsyslog-2.0.0/net.c
--- rsyslog-2.0.0/net.c.strerror 2008-01-22 11:58:11.000000000 +0100
+++ rsyslog-2.0.0/net.c 2008-01-22 12:14:37.000000000 +0100
@@ -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>
diff -up rsyslog-2.0.0/pidfile.c.strerror rsyslog-2.0.0/pidfile.c
diff -up rsyslog-2.0.0/tcpsyslog.c.strerror rsyslog-2.0.0/tcpsyslog.c
--- rsyslog-2.0.0/tcpsyslog.c.strerror 2008-01-22 12:00:05.000000000 +0100
+++ rsyslog-2.0.0/tcpsyslog.c 2008-01-22 12:15:29.000000000 +0100
@@ -1021,7 +1021,7 @@ int TCPSendCreateSocket(struct addrinfo
} 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
}
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;
}
diff -up rsyslog-2.0.0/syslogd.h.strerror rsyslog-2.0.0/syslogd.h
--- rsyslog-2.0.0/syslogd.h.strerror 2008-01-22 12:00:12.000000000 +0100
+++ rsyslog-2.0.0/syslogd.h 2008-01-22 12:01:04.000000000 +0100
@@ -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);

View File

@ -3,7 +3,7 @@
Summary: Enhanced system logging and kernel message trapping daemons
Name: rsyslog
Version: 2.0.0
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
Group: System Environment/Daemons
URL: http://www.rsyslog.com/
@ -11,6 +11,7 @@ Source0: http://download.rsyslog.com/rsyslog/%{name}-%{version}.tar.gz
Source1: rsyslog.init
Source2: rsyslog.sysconfig
Patch1: rsyslog-2.0.0-sockhang.patch
Patch2: rsyslog-2.0.0-strerror.patch
BuildRequires: zlib-devel
BuildRequires: autoconf automake
Requires: logrotate >= 3.5.2
@ -46,6 +47,8 @@ MySQL database support to rsyslog.
%prep
%setup -q
%patch1 -p1 -b .sockHang
%patch2 -p1 -b .strerror
autoreconf
%build
%configure --sbindir=%{sbindir} --disable-static --enable-mysql
@ -118,6 +121,9 @@ fi
%{_libdir}/rsyslog/ommysql.so
%changelog
* Tue Jan 22 2008 Peter Vrabec <pvrabec@redhat.com> 2.0.0-2
- strerror fix (#428775)
* Thu Jan 17 2008 Peter Vrabec <pvrabec@redhat.com> 2.0.0-1
- upgrade
- fixing bad file descriptor (#428775)