journal-importer: cap field size when checking

Originally reported on yeswehack.com as YWH-PGM9780-82

Follow-up for 1e448731f5
This commit is contained in:
Luca Boccassi
2026-06-07 21:49:43 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent ce31ff043e
commit 5d31694318
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -325,7 +325,7 @@ int journal_importer_process_data(JournalImporter *imp) {
if (!journal_field_valid(line, sep - line, true)) {
char buf[64], *t;
t = strndupa_safe(line, sep - line);
t = strndupa_safe(line, MIN((size_t) (sep - line), sizeof buf));
log_debug("Ignoring invalid field: \"%s\"",
cellescape(buf, sizeof buf, t));
@@ -344,7 +344,7 @@ int journal_importer_process_data(JournalImporter *imp) {
if (!journal_field_valid(line, n - 1, true)) {
char buf[64], *t;
t = strndupa_safe(line, n - 1);
t = strndupa_safe(line, MIN(n - 1, sizeof buf));
log_debug("Ignoring invalid field: \"%s\"",
cellescape(buf, sizeof buf, t));
@@ -310,3 +310,15 @@ systemctl stop systemd-journal-remote.{socket,service}
rm -rf /var/log/journal/remote/*
rm /run/systemd/journal-upload.conf.d/99-test.conf
rm /run/systemd/journal-remote.conf.d/99-test.conf
DOS_DIR="$(mktemp -d)"
{ head -c $((5 * 1024 * 1024)) /dev/zero | tr '\0' 'A'; printf '\n'; } >"$DOS_DIR/no-separator.export"
{ head -c $((5 * 1024 * 1024)) /dev/zero | tr '\0' 'A'; printf '=value\n'; } >"$DOS_DIR/long-field-name.export"
for export_file in "$DOS_DIR"/no-separator.export "$DOS_DIR"/long-field-name.export; do
rm -f "$DOS_DIR"/*.journal
timeout 30 /usr/lib/systemd/systemd-journal-remote \
--split-mode=none \
--output="$DOS_DIR/dos.journal" \
"$export_file" || [[ $? -lt 124 ]]
done
rm -rf "$DOS_DIR"