From 3d9e235072f6d219181a12b003112d5315544649 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Fri, 17 Apr 2015 14:43:59 +0200 Subject: [PATCH] ccpp: check for overflow in abrt coredump path creation This issue was discovered by Florian Weimer of Red Hat Product Security. Signed-off-by: Jakub Filak --- src/hooks/abrt-hook-ccpp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c index 92413e3..53700e4 100644 --- a/src/hooks/abrt-hook-ccpp.c +++ b/src/hooks/abrt-hook-ccpp.c @@ -592,7 +592,9 @@ int main(int argc, char** argv) * and maybe crash again... * Unlike dirs, mere files are ignored by abrtd. */ - snprintf(path, sizeof(path), "%s/%s-coredump", g_settings_dump_location, last_slash); + if (snprintf(path, sizeof(path), "%s/%s-coredump", g_settings_dump_location, last_slash) >= sizeof(path)) + error_msg_and_die("Error saving '%s': truncated long file path", path); + int abrt_core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0600); off_t core_size = copyfd_eof(STDIN_FILENO, abrt_core_fd, COPYFD_SPARSE); if (core_size < 0 || fsync(abrt_core_fd) != 0) -- 2.1.0