Apply a patch from Evin Robertson -- new pivot_root applet.
[oweals/busybox.git] / logger.c
index 21906401f502c7df5cf7bc1c29902d41ce81efc9..85c63b8a5a13a57306fccdc53225204c27b68329 100644 (file)
--- a/logger.c
+++ b/logger.c
@@ -2,7 +2,7 @@
 /*
  * Mini logger implementation for busybox
  *
- * Copyright (C) 1999,2000 by Lineo, inc.
+ * Copyright (C) 1999,2000,2001 by Lineo, inc.
  * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -27,6 +27,8 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
 
 #if !defined BB_SYSLOGD
 
@@ -85,14 +87,14 @@ static int pencode(char *s)
                *s = '\0';
                fac = decode(save, facilitynames);
                if (fac < 0)
-                       error_msg_and_die("unknown facility name: %s\n", save);
+                       error_msg_and_die("unknown facility name: %s", save);
                *s++ = '.';
        } else {
                s = save;
        }
        lev = decode(s, prioritynames);
        if (lev < 0)
-               error_msg_and_die("unknown priority name: %s\n", save);
+               error_msg_and_die("unknown priority name: %s", save);
        return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
 }
 
@@ -130,6 +132,7 @@ extern int logger_main(int argc, char **argv)
                while ((c = getc(stdin)) != EOF && i < sizeof(buf)) {
                        buf[i++] = c;
                }
+               buf[i++] = '\0';
                message = buf;
        } else {
                len = 1; /* for the '\0' */
@@ -147,7 +150,6 @@ extern int logger_main(int argc, char **argv)
        openlog(name, option, (pri | LOG_FACMASK));
        syslog(pri, "%s", message);
        closelog();
-
        return EXIT_SUCCESS;
 }