Dear collegues, do you have any objections for merging syslog overflow fix from OpenBSD? The patch I'm going to commit is at end of this message. Problem description and PoC can be found in bin/72366. Index: syslog.c =================================================================== RCS file: /home/ncvs/src/lib/libc/gen/syslog.c,v retrieving revision 1.30 diff -u -r1.30 syslog.c --- syslog.c 10 May 2004 17:12:52 -0000 1.30 +++ syslog.c 6 Oct 2004 12:32:05 -0000 _at__at_ -243,17 +243,27 _at__at_ if (!opened) openlog(LogTag, LogStat | LOG_NDELAY, 0); connectlog(); - if (send(LogFile, tbuf, cnt, 0) >= 0) - return; /* - * If the send() failed, the odds are syslogd was restarted. - * Make one (only) attempt to reconnect to /dev/log. + * If the send() failed, there are two likely scenarios: + * 1) syslogd was restarted + * 2) /var/run/log is out of socket buffer space + * We attempt to reconnect to /var/run/log to take care of + * case #1 and keep send()ing data to cover case #2 + * to give syslogd a chance to empty its socket buffer. */ - disconnectlog(); - connectlog(); - if (send(LogFile, tbuf, cnt, 0) >= 0) - return; + + if (send(LogFile, tbuf, cnt, 0) < 0) { + if (errno != ENOBUFS) { + disconnectlog(); + connectlog(); + } + do { + usleep(1); + if (send(LogFile, tbuf, cnt, 0) >= 0) + break; + } while (errno == ENOBUFS); + } /* * Output the message to the console; try not to block -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPEReceived on Wed Oct 06 2004 - 10:43:43 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:15 UTC