diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-06 11:34:03 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-06 11:34:03 +0000 |
commit | cb12cb240714f2599addd4ec61ef336ab87482cd (patch) | |
tree | eb218e0c85ceb81753cb3a27535b93069d4ebb7a | |
parent | 52816302299854ba1644fce98b5d19db526e6c29 (diff) | |
download | busybox-w32-cb12cb240714f2599addd4ec61ef336ab87482cd.tar.gz busybox-w32-cb12cb240714f2599addd4ec61ef336ab87482cd.tar.bz2 busybox-w32-cb12cb240714f2599addd4ec61ef336ab87482cd.zip |
modprobe: fix a bug where we were entering endless loop
syslogd: strip trailing '\n' too, not only NULs
-rw-r--r-- | modutils/modprobe.c | 2 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index f7d193a05..dafbb4ecd 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -791,7 +791,7 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t | |||
791 | if (*tail) | 791 | if (*tail) |
792 | (*tail)->m_next = find; | 792 | (*tail)->m_next = find; |
793 | find->m_prev = *tail; | 793 | find->m_prev = *tail; |
794 | /*find->m_next = NULL; - xzalloc did it */ | 794 | find->m_next = NULL; /* possibly NOT done by xzalloc! */ |
795 | 795 | ||
796 | if (!*head) | 796 | if (!*head) |
797 | *head = find; | 797 | *head = find; |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 2bf5b5c80..da63ced42 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -536,10 +536,20 @@ static void do_syslogd(void) | |||
536 | while (1) { | 536 | while (1) { |
537 | if (sz == 0) | 537 | if (sz == 0) |
538 | goto read_again; | 538 | goto read_again; |
539 | if (G.recvbuf[sz-1]) | 539 | /* man 3 syslog says: "A trailing newline is added when needed". |
540 | * However, neither glibc nor uclibc do this: | ||
541 | * syslog(prio, "test") sends "test\0" to /dev/log, | ||
542 | * syslog(prio, "test\n") sends "test\n\0", | ||
543 | * IOW: newline is passed verbatim! | ||
544 | * I take it to mean that it's syslogd's job | ||
545 | * to make those look identical in the log files */ | ||
546 | if (G.recvbuf[sz-1] && G.recvbuf[sz-1] != '\n') | ||
540 | break; | 547 | break; |
541 | sz--; | 548 | sz--; |
542 | } | 549 | } |
550 | /* Maybe we need to add '\n' here, not later? | ||
551 | * It looks like stock syslogd does send '\n' over network, | ||
552 | * but we do not (see sendto below) */ | ||
543 | G.recvbuf[sz] = '\0'; /* make sure it *is* NUL terminated */ | 553 | G.recvbuf[sz] = '\0'; /* make sure it *is* NUL terminated */ |
544 | 554 | ||
545 | /* TODO: maybe suppress duplicates? */ | 555 | /* TODO: maybe suppress duplicates? */ |