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 <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2024-02-26 15:58:52 -10:00
parent c0c6a0e352
commit f93b995370

View File

@ -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;
}