arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone
Blob Blame History Raw
From 80d2c8604e4dae2fccad721eae0b219376a6ffce Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Thu, 21 Apr 2016 11:20:40 +0200
Subject: [PATCH] ccpp: exit with error if cannot get executable

Related to rhbz#1277849

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
 src/hooks/abrt-hook-ccpp.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index c9fbf68..8afd0d3 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -703,13 +703,16 @@ static void error_msg_not_process_crash(const char *pid_str, const char *process
     char *message_full = xvasprintf(message, p);
     va_end(p);
 
+    char *process_name = (process_str) ?  xasprintf(" (%s)", process_str) : xstrdup("");
+
     if (signame)
         error_msg("Process %s (%s) of user %lu killed by SIG%s - %s", pid_str,
-                        process_str, uid, signame, message_full);
+                        process_name, uid, signame, message_full);
     else
         error_msg("Process %s (%s) of user %lu killed by signal %d - %s", pid_str,
-                        process_str, uid, signal_no, message_full);
+                        process_name, uid, signal_no, message_full);
 
+    free(process_name);
     free(message_full);
 
     return;
@@ -835,6 +838,10 @@ int main(int argc, char** argv)
 
     int src_fd_binary = -1;
     char *executable = get_executable(pid, setting_SaveBinaryImage ? &src_fd_binary : NULL);
+    if (executable == NULL)
+        error_msg_not_process_crash(pid_str, NULL, (long unsigned)uid, signal_no,
+                signame, "ignoring (can't read /proc/PID/exe link)");
+
     if (executable && strstr(executable, "/abrt-hook-ccpp"))
     {
         error_msg_and_die("PID %lu is '%s', not dumping it to avoid recursion",
-- 
1.8.3.1