systemd/1278-coredump-make-check-that-all-argv-meta-data-fields-a.patch
Jan Macku a673ceed38 systemd-252-60
Resolves: RHEL-115182,RHEL-97175,RHEL-107268
2025-11-05 09:44:11 +01:00

35 lines
1.4 KiB
Diff

From 9109aaae160fe7dcb9390829db619e4e8f90274f Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 31 Oct 2024 17:02:59 +0100
Subject: [PATCH] coredump: make check that all argv[] meta data fields are
passed strict
Otherwise, if some field is not supplied we might end up parsing a NULL
string later. Let's catch that early.
(cherry picked from commit 098c3975acb3df61eedfe471fca27c21f13cf04c)
Related: RHEL-104138
---
src/coredump/coredump.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index dca78fa72c..b24f4c8cc3 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -1067,9 +1067,10 @@ static int save_context(Context *context, const struct iovec_wrapper *iovw) {
}
}
- 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]);
r = parse_pid(context->meta[META_ARGV_PID], &context->pid);
if (r < 0)