Blob Blame History Raw
From 3853f65022ef450469a6f612fe1ae11ab3f87a8a Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Thu, 26 May 2016 10:15:07 +0200
Subject: [PATCH] abrt-hook-ccpp: save get_fsuid() return values in int
 variables

int because get_fsuid() returns negative values in case of error
Revealed by coverity.

Related to: #1337186

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

diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index dc4dec6..581a540 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -863,7 +863,8 @@ int main(int argc, char** argv)
     char *proc_pid_status = xmalloc_xopen_read_close(path, /*maxsz:*/ NULL);
 
     uid_t fsuid = uid;
-    uid_t tmp_fsuid = get_fsuid(proc_pid_status);
+    /* int because get_fsuid() returns negative values in case of error */
+    int tmp_fsuid = get_fsuid(proc_pid_status);
     if (tmp_fsuid < 0)
     {
         error_msg_ignore_crash(pid_str, NULL, (long unsigned)uid, signal_no,
@@ -879,12 +880,12 @@ int main(int argc, char** argv)
     }
 
     int suid_policy = dump_suid_policy();
-    if (tmp_fsuid != uid)
+    if ((uid_t)tmp_fsuid != uid)
     {
         /* use root for suided apps unless it's explicitly set to UNSAFE */
         fsuid = 0;
         if (suid_policy == DUMP_SUID_UNSAFE)
-            fsuid = tmp_fsuid;
+            fsuid = (uid_t)tmp_fsuid;
         else
         {
             g_user_core_flags = O_EXCL;
-- 
1.8.3.1