]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: make check that all argv[] meta data fields are passed strict 34970/head
authorLennart Poettering <lennart@poettering.net>
Thu, 31 Oct 2024 16:02:59 +0000 (17:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 31 Oct 2024 22:09:14 +0000 (23:09 +0100)
Otherwise, if some field is not supplied we might end up parsing a NULL
string later. Let's catch that early.

src/coredump/coredump.c

index f2acf8c37f7a31024f2a8b37b0513fe5a6289646..c3e97325e0c3f9467abb03eb52cd202250d37633 100644 (file)
@@ -1045,9 +1045,10 @@ static int context_parse_iovw(Context *context, struct iovec_wrapper *iovw) {
                         memory_startswith(iovec->iov_base, iovec->iov_len, "COREDUMP_SIGNAL_NAME=");
         }
 
-        if (!context->meta[META_ARGV_PID])
-                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                       "Failed to find the PID of crashing process");
+        /* The basic fields from argv[] should always be there, refuse early if not */
+        for (int i = 0; i < _META_ARGV_MAX; i++)
+                if (!context->meta[i])
+                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "A required (%s) has not been sent, aborting.", meta_field_names[i]);
 
         pid_t parsed_pid;
         r = parse_pid(context->meta[META_ARGV_PID], &parsed_pid);