diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-05-16 08:35:02 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-05-16 08:35:02 +0000 |
commit | 900c8f3362c4f694fea300c4f36322271659ff87 (patch) | |
tree | e3ca02e3011b8838e35d908d57bbf90813e180e6 /sysklogd | |
parent | d3af409eaecb900c6133ac138572080c8cb43fb4 (diff) |
Apply patch from Georg Magschok to fix syslog behavior so that the
'>' charactor can be logged, per rfc3164.
Also, a small patch from me to fix it so we use MAXLINE when allocating the
buffer, which is consistant with use everywhere else. This is needed since
uClibc defines BUFSIZE as 255, causing lines to be truncated at 255...
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index b912f5f8f..bafbaa35b 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -426,19 +426,29 @@ static int serveConnection(char *tmpbuf, int n_read) int pri = (LOG_USER | LOG_NOTICE); char line[MAXLINE + 1]; unsigned char c; - char *q = line; + char *p1 = 0; + int oldpri; while ((c = *p) && q < &line[sizeof(line) - 1]) { - if (c == '<') { + if (c == '<' && p1 == 0) { /* Parse the magic priority number. */ + p1 = p; + oldpri = pri; pri = 0; while (isdigit(*(++p))) { pri = 10 * pri + (*p - '0'); } - if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) { - pri = (LOG_USER | LOG_NOTICE); - } + if ( *p != '>') { + *q++ = c; + p=p1; + p1=0; + pri=oldpri; + } else { + if (pri & ~(LOG_FACMASK | LOG_PRIMASK)){ + pri = (LOG_USER | LOG_NOTICE); + } + } } else if (c == '\n') { *q++ = ' '; } else if (iscntrl(c) && (c < 0177)) { @@ -563,10 +573,10 @@ static void doSyslogd(void) if (FD_ISSET(sock_fd, &fds)) { int i; - RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZ + 1); + RESERVE_CONFIG_BUFFER(tmpbuf, MAXLINE + 1); - memset(tmpbuf, '\0', BUFSIZ + 1); - if ((i = recv(sock_fd, tmpbuf, BUFSIZ, 0)) > 0) { + memset(tmpbuf, '\0', MAXLINE + 1); + if ((i = recv(sock_fd, tmpbuf, MAXLINE, 0)) > 0) { serveConnection(tmpbuf, i); } else { bb_perror_msg_and_die("UNIX socket error"); |