journal: do not pass a negative value to memcpy()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Aug 2018 03:40:44 +0000 (12:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Aug 2018 03:40:47 +0000 (12:40 +0900)
The message may contains only whitespaces.

Fixes #9795.

src/journal/journald-syslog.c

index 08b4fcb..2de3bdf 100644 (file)
@@ -333,7 +333,10 @@ void server_process_syslog_message(
 
         leading_ws = strspn(buf, WHITESPACE);
 
-        if (i == raw_len)
+        if (i == 0)
+                /* The message contains only whitespaces */
+                msg = buf + raw_len;
+        else if (i == raw_len)
                 /* Nice! No need to strip anything on the end, let's optimize this a bit */
                 msg = buf + leading_ws;
         else {