Skip to content

Commit

Permalink
linux-user/elfload: Disable core dump if getrlimit fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rth7680 committed Feb 29, 2024
1 parent c0c6a0e commit f93b995
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f93b995

Please sign in to comment.