Blob Blame Raw
From 5c011b291a65f88036884bf388859e68fe7162a9 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 dfe9526..10f137b 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -725,7 +725,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,
@@ -742,12 +743,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;
-- 
2.7.4