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:
commit
9e5f34a639
|
@ -93,7 +93,7 @@ static bool is_us(const char *identifier, const char *pid) {
|
||||||
streq(identifier, program_invocation_short_name);
|
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;
|
_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];
|
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);
|
e = memchr(k, '\n', l);
|
||||||
if (!e)
|
if (!e)
|
||||||
return;
|
goto finish;
|
||||||
|
|
||||||
*e = 0;
|
*e = 0;
|
||||||
|
|
||||||
|
|
|
@ -222,8 +222,9 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid)
|
||||||
if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
|
if (p[e] != '\0' && strchr(WHITESPACE, p[e]))
|
||||||
e++;
|
e++;
|
||||||
|
|
||||||
|
l = (p - *buf) + e;
|
||||||
*buf = p + e;
|
*buf = p + e;
|
||||||
return e;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int syslog_skip_timestamp(const char **buf) {
|
static int syslog_skip_timestamp(const char **buf) {
|
||||||
|
|
|
@ -41,6 +41,8 @@ int main(void) {
|
||||||
test_syslog_parse_identifier(" ", NULL, NULL, " ", 0);
|
test_syslog_parse_identifier(" ", NULL, NULL, " ", 0);
|
||||||
test_syslog_parse_identifier(":", "", NULL, "", 1);
|
test_syslog_parse_identifier(":", "", NULL, "", 1);
|
||||||
test_syslog_parse_identifier(": ", "", NULL, " ", 2);
|
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, "", 5);
|
||||||
test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
|
test_syslog_parse_identifier("pidu: ", "pidu", NULL, "", 6);
|
||||||
test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);
|
test_syslog_parse_identifier("pidu : ", NULL, NULL, "pidu : ", 0);
|
||||||
|
|
Loading…
Reference in a new issue