Merge pull request #9863 from evverx/issues-found-by-journald-fuzzer

A few fixes for several issues uncovered with a home-brew fuzzer for journald
This commit is contained in:
Yu Watanabe 2018-08-13 20:57:25 +09:00 committed by GitHub
commit 9e5f34a639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -93,7 +93,7 @@ static bool is_us(const char *identifier, const char *pid) {
streq(identifier, program_invocation_short_name);
}
static void dev_kmsg_record(Server *s, const char *p, size_t l) {
static void dev_kmsg_record(Server *s, char *p, size_t l) {
_cleanup_free_ char *message = NULL, *syslog_priority = NULL, *syslog_pid = NULL, *syslog_facility = NULL, *syslog_identifier = NULL, *source_time = NULL, *identifier = NULL, *pid = NULL;
struct iovec iovec[N_IOVEC_META_FIELDS + 7 + N_IOVEC_KERNEL_FIELDS + 2 + N_IOVEC_UDEV_FIELDS];
@ -191,7 +191,7 @@ static void dev_kmsg_record(Server *s, const char *p, size_t l) {
e = memchr(k, '\n', l);
if (!e)
return;
goto finish;
*e = 0;

View File

@ -222,8 +222,9 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid)
if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
e++;
l = (p - *buf) + e;
*buf = p + e;
return e;
return l;
}
static int syslog_skip_timestamp(const char **buf) {

View File

@ -41,6 +41,8 @@ int main(void) {
test_syslog_parse_identifier(" ", NULL, NULL, " ", 0);
test_syslog_parse_identifier(":", "", NULL, "", 1);
test_syslog_parse_identifier(": ", "", NULL, " ", 2);
test_syslog_parse_identifier(" :", "", NULL, "", 2);
test_syslog_parse_identifier(" pidu:", "pidu", NULL, "", 8);
test_syslog_parse_identifier("pidu:", "pidu", NULL, "", 5);
test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);