chiark / gitweb /
journald: check return value of strappend
[elogind.git] / src / journal / journald-kmsg.c
index 4f5e7a0c52f2ad3c5df5e48a07f25b4ef03ffe26..2f536320f8d90d41a8eff6740a55da8051ed83a7 100644 (file)
@@ -28,7 +28,7 @@
 #include <systemd/sd-messages.h>
 #include <libudev.h>
 
-#include "journald.h"
+#include "journald-server.h"
 #include "journald-kmsg.h"
 #include "journald-syslog.h"
 
@@ -109,7 +109,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
         char *message = NULL, *syslog_priority = NULL, *syslog_pid = NULL, *syslog_facility = NULL, *syslog_identifier = NULL, *source_time = NULL;
         int priority, r;
         unsigned n = 0, z = 0, j;
-        usec_t usec;
+        unsigned long long usec;
         char *identifier = NULL, *pid = NULL, *e, *f, *k;
         uint64_t serial;
         size_t pl;
@@ -171,7 +171,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
                 e = f;
         *e = 0;
 
-        r = parse_usec(p, &usec);
+        r = safe_atollu(p, &usec);
         if (r < 0)
                 return;
 
@@ -250,10 +250,12 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
                                         break;
 
                                 g = udev_list_entry_get_name(ll);
-                                b = strappend("_UDEV_DEVLINK=", g);
                                 if (g) {
-                                        IOVEC_SET_STRING(iovec[n++], b);
-                                        z++;
+                                        b = strappend("_UDEV_DEVLINK=", g);
+                                        if (b) {
+                                                IOVEC_SET_STRING(iovec[n++], b);
+                                                z++;
+                                        }
                                 }
 
                                 j++;
@@ -263,8 +265,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
                 }
         }
 
-        if (asprintf(&source_time, "_SOURCE_MONOTONIC_TIMESTAMP=%llu",
-                     (unsigned long long) usec) >= 0)
+        if (asprintf(&source_time, "_SOURCE_MONOTONIC_TIMESTAMP=%llu", usec) >= 0)
                 IOVEC_SET_STRING(iovec[n++], source_time);
 
         IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=kernel");
@@ -275,7 +276,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
         if ((priority & LOG_FACMASK) == LOG_KERN)
                 IOVEC_SET_STRING(iovec[n++], "SYSLOG_IDENTIFIER=kernel");
         else {
-                syslog_parse_identifier((const char**) &p, &identifier, &pid);
+                pl -= syslog_parse_identifier((const char**) &p, &identifier, &pid);
 
                 /* Avoid any messages we generated ourselves via
                  * log_info() and friends. */