Blame 0181-ccpp-save-abrt-core-files-only-to-new-files.patch

69165ba
From f982995841607f06faaa055740310e0520c07c67 Mon Sep 17 00:00:00 2001
69165ba
From: Jakub Filak <jfilak@redhat.com>
69165ba
Date: Wed, 30 Sep 2015 12:24:32 +0200
69165ba
Subject: [PATCH] ccpp: save abrt core files only to new files
69165ba
69165ba
Prior this commit abrt-hook-ccpp saved a core file generated by a
69165ba
process running a program whose name starts with "abrt" in
69165ba
DUMP_LOCATION/$(basename program)-coredump. If the file was a symlink,
69165ba
the hook followed and wrote core file to the symlink's target.
69165ba
69165ba
This commit addresses CVE-2015-5287
69165ba
Related: #1262252
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 src/hooks/abrt-hook-ccpp.c | 3 ++-
69165ba
 1 file changed, 2 insertions(+), 1 deletion(-)
69165ba
69165ba
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
69165ba
index 7a19cc2..9648b16 100644
69165ba
--- a/src/hooks/abrt-hook-ccpp.c
69165ba
+++ b/src/hooks/abrt-hook-ccpp.c
69165ba
@@ -857,7 +857,8 @@ int main(int argc, char** argv)
69165ba
         if (snprintf(path, sizeof(path), "%s/%s-coredump", g_settings_dump_location, last_slash) >= sizeof(path))
69165ba
             error_msg_and_die("Error saving '%s': truncated long file path", path);
69165ba
 
69165ba
-        int abrt_core_fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
69165ba
+        unlink(path);
69165ba
+        int abrt_core_fd = xopen3(path, O_WRONLY | O_CREAT | O_EXCL, 0600);
69165ba
         off_t core_size = copyfd_eof(STDIN_FILENO, abrt_core_fd, COPYFD_SPARSE);
69165ba
         if (core_size < 0 || fsync(abrt_core_fd) != 0)
69165ba
         {
69165ba
-- 
69165ba
1.8.3.1
69165ba