From: Richard Henderson Date: Tue, 27 Feb 2024 01:58:52 +0000 (-1000) Subject: linux-user/elfload: Disable core dump if getrlimit fails X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f93b9953703be41408d5f0e09a871775d4be3c36;p=qemu.git linux-user/elfload: Disable core dump if getrlimit fails Do not dump core at all if getrlimit fails; this ensures that dumpsize is valid throughout the function, not just for the initial test vs rlim_cur. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b8eef893d0..fb47fe39c9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4673,7 +4673,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) return 0; } - if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) { + if (getrlimit(RLIMIT_CORE, &dumpsize) < 0 || dumpsize.rlim_cur == 0) { return 0; }