summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2003-11-16 21:51:06 +0000
committerdwmalone <dwmalone@FreeBSD.org>2003-11-16 21:51:06 +0000
commit0146715061514e61750069f049e3d6d08d20409c (patch)
tree04b8138ea35be91b01435250e726b7c8a8f77cce /usr.sbin
parent898b9151c23c6a84f9599085231de4b26a6e09cd (diff)
downloadFreeBSD-src-0146715061514e61750069f049e3d6d08d20409c.zip
FreeBSD-src-0146715061514e61750069f049e3d6d08d20409c.tar.gz
logerror is used in syslogd to log errors from syslogd itself. It
is possible for an error to occur while trying to log an error, and this can result in infinite recursion (or at least until we run out of stack). Rather than this, we ignore requests to log an error while logging an error. PR: 51253 MFC after: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index f2d0874..c47dfa9 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1338,7 +1338,12 @@ static void
logerror(const char *type)
{
char buf[512];
+ static int recursed = 0;
+ /* If there's an error while trying to log an error, give up. */
+ if (recursed)
+ return;
+ recursed++;
if (errno)
(void)snprintf(buf,
sizeof buf, "syslogd: %s: %s", type, strerror(errno));
@@ -1347,6 +1352,7 @@ logerror(const char *type)
errno = 0;
dprintf("%s\n", buf);
logmsg(LOG_SYSLOG|LOG_ERR, buf, LocalHostName, ADDDATE);
+ recursed--;
}
static void
OpenPOWER on IntegriCloud