Blame 0233-abrt-hook-ccpp-save-get_fsuid-return-values-in-int-v.patch

69165ba
From 3853f65022ef450469a6f612fe1ae11ab3f87a8a Mon Sep 17 00:00:00 2001
69165ba
From: Matej Habrnal <mhabrnal@redhat.com>
69165ba
Date: Thu, 26 May 2016 10:15:07 +0200
69165ba
Subject: [PATCH] abrt-hook-ccpp: save get_fsuid() return values in int
69165ba
 variables
69165ba
69165ba
int because get_fsuid() returns negative values in case of error
69165ba
Revealed by coverity.
69165ba
69165ba
Related to: #1337186
69165ba
69165ba
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
69165ba
---
69165ba
 src/hooks/abrt-hook-ccpp.c | 7 ++++---
69165ba
 1 file changed, 4 insertions(+), 3 deletions(-)
69165ba
69165ba
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
69165ba
index dc4dec6..581a540 100644
69165ba
--- a/src/hooks/abrt-hook-ccpp.c
69165ba
+++ b/src/hooks/abrt-hook-ccpp.c
69165ba
@@ -863,7 +863,8 @@ int main(int argc, char** argv)
69165ba
     char *proc_pid_status = xmalloc_xopen_read_close(path, /*maxsz:*/ NULL);
69165ba
 
69165ba
     uid_t fsuid = uid;
69165ba
-    uid_t tmp_fsuid = get_fsuid(proc_pid_status);
69165ba
+    /* int because get_fsuid() returns negative values in case of error */
69165ba
+    int tmp_fsuid = get_fsuid(proc_pid_status);
69165ba
     if (tmp_fsuid < 0)
69165ba
     {
69165ba
         error_msg_ignore_crash(pid_str, NULL, (long unsigned)uid, signal_no,
69165ba
@@ -879,12 +880,12 @@ int main(int argc, char** argv)
69165ba
     }
69165ba
 
69165ba
     int suid_policy = dump_suid_policy();
69165ba
-    if (tmp_fsuid != uid)
69165ba
+    if ((uid_t)tmp_fsuid != uid)
69165ba
     {
69165ba
         /* use root for suided apps unless it's explicitly set to UNSAFE */
69165ba
         fsuid = 0;
69165ba
         if (suid_policy == DUMP_SUID_UNSAFE)
69165ba
-            fsuid = tmp_fsuid;
69165ba
+            fsuid = (uid_t)tmp_fsuid;
69165ba
         else
69165ba
         {
69165ba
             g_user_core_flags = O_EXCL;
69165ba
-- 
69165ba
1.8.3.1
69165ba