aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-16 08:35:02 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-16 08:35:02 +0000
commit71d10cced6a6134cd3671c0651cb787cafbf88d7 (patch)
treee3ca02e3011b8838e35d908d57bbf90813e180e6
parent307ab12d97d7d478fb3d1a9181058ebb70d96d74 (diff)
downloadbusybox-w32-71d10cced6a6134cd3671c0651cb787cafbf88d7.tar.gz
busybox-w32-71d10cced6a6134cd3671c0651cb787cafbf88d7.tar.bz2
busybox-w32-71d10cced6a6134cd3671c0651cb787cafbf88d7.zip
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... git-svn-id: svn://busybox.net/trunk/busybox@6844 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--sysklogd/syslogd.c26
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)
426 int pri = (LOG_USER | LOG_NOTICE); 426 int pri = (LOG_USER | LOG_NOTICE);
427 char line[MAXLINE + 1]; 427 char line[MAXLINE + 1];
428 unsigned char c; 428 unsigned char c;
429
430 char *q = line; 429 char *q = line;
430 char *p1 = 0;
431 int oldpri;
431 432
432 while ((c = *p) && q < &line[sizeof(line) - 1]) { 433 while ((c = *p) && q < &line[sizeof(line) - 1]) {
433 if (c == '<') { 434 if (c == '<' && p1 == 0) {
434 /* Parse the magic priority number. */ 435 /* Parse the magic priority number. */
436 p1 = p;
437 oldpri = pri;
435 pri = 0; 438 pri = 0;
436 while (isdigit(*(++p))) { 439 while (isdigit(*(++p))) {
437 pri = 10 * pri + (*p - '0'); 440 pri = 10 * pri + (*p - '0');
438 } 441 }
439 if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) { 442 if ( *p != '>') {
440 pri = (LOG_USER | LOG_NOTICE); 443 *q++ = c;
441 } 444 p=p1;
445 p1=0;
446 pri=oldpri;
447 } else {
448 if (pri & ~(LOG_FACMASK | LOG_PRIMASK)){
449 pri = (LOG_USER | LOG_NOTICE);
450 }
451 }
442 } else if (c == '\n') { 452 } else if (c == '\n') {
443 *q++ = ' '; 453 *q++ = ' ';
444 } else if (iscntrl(c) && (c < 0177)) { 454 } else if (iscntrl(c) && (c < 0177)) {
@@ -563,10 +573,10 @@ static void doSyslogd(void)
563 if (FD_ISSET(sock_fd, &fds)) { 573 if (FD_ISSET(sock_fd, &fds)) {
564 int i; 574 int i;
565 575
566 RESERVE_CONFIG_BUFFER(tmpbuf, BUFSIZ + 1); 576 RESERVE_CONFIG_BUFFER(tmpbuf, MAXLINE + 1);
567 577
568 memset(tmpbuf, '\0', BUFSIZ + 1); 578 memset(tmpbuf, '\0', MAXLINE + 1);
569 if ((i = recv(sock_fd, tmpbuf, BUFSIZ, 0)) > 0) { 579 if ((i = recv(sock_fd, tmpbuf, MAXLINE, 0)) > 0) {
570 serveConnection(tmpbuf, i); 580 serveConnection(tmpbuf, i);
571 } else { 581 } else {
572 bb_perror_msg_and_die("UNIX socket error"); 582 bb_perror_msg_and_die("UNIX socket error");