From: Lennart Poettering Date: Mon, 21 Mar 2022 17:12:53 +0000 (+0100) Subject: sd-journal: refuse invocation of journal_file_open() with O_RDONLY|O_CREAT X-Git-Tag: v251-rc1~82^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d120d897eca011cd782a9e4074d91e25b6d76895;p=thirdparty%2Fsystemd.git sd-journal: refuse invocation of journal_file_open() with O_RDONLY|O_CREAT --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index ac8ad145eda..e7014196c8d 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -3336,6 +3336,9 @@ int journal_file_open( if (!IN_SET((flags & O_ACCMODE), O_RDONLY, O_RDWR)) return -EINVAL; + if ((flags & O_ACCMODE) == O_RDONLY && FLAGS_SET(flags, O_CREAT)) + return -EINVAL; + if (fname && (flags & O_CREAT) && !endswith(fname, ".journal")) return -EINVAL;