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
This commit is contained in:
David Malone 2003-11-16 21:51:06 +00:00
parent 3c453e20f9
commit de4aac0deb

View File

@ -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