]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-journal: make sure sd_journal_add_match() also accepts SIZE_MAX as size
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Apr 2024 15:51:54 +0000 (17:51 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Apr 2024 07:54:03 +0000 (16:54 +0900)
commite1771c8ee63f1ce5c3febfdba27089b361f7cf4e
tree60fb92a9a2810a6ff990aa6bee69a3e3680f0a55
parent7072777163bef1877d65dce07e0914cf57c6ea38
sd-journal: make sure sd_journal_add_match() also accepts SIZE_MAX as size

In many of our internal functions that take a pointer + a size we have
introduced the rule that SIZE_MAX as size means: take strlen().

sd_journal_add_match() has something similar, but the special value is
0, not SIZE_MAX. This is a bit ugly, since a zero size data block is
theoretically fine. The only reason sd_journal_add_match() gets away
with using this special value is because valid matches must consist of
at least 2 chars, hence cannot be zero.

But let's make this more robust and less surprising when compared to the
rest of our code, and *also* accept SIZE_MAX to mean strlen().

No actual code changes, just some clean-up.
src/coredump/coredumpctl.c
src/journal/bsod.c
src/journal/journalctl-filter.c
src/libsystemd/sd-journal/sd-journal.c
src/libsystemd/sd-journal/test-journal-enum.c
src/libsystemd/sd-journal/test-journal-match.c
src/libsystemd/sd-journal/test-journal-stream.c
src/shared/logs-show.c