[gvfs/gnome-3-22] admin: Fix strtol error check



commit ddc1b701f929e47397abcea058505fec1298ef10
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Mar 17 13:34:51 2017 +0100

    admin: Fix strtol error check
    
    The result from strtol is stored in uid_t and then checked for
    LONG_MAX and LONG_MIN, however, uid_t doesn't have to be long. Let's
    check just the errno value, it should be enough.
    
    This issue was revealed by coverity scan.

 daemon/gvfsbackendadmin.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 4107d6f..66c9379 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -941,9 +941,9 @@ g_vfs_backend_admin_pre_setup (int *argc,
   if (pkexec_uid == NULL)
     g_error ("gvfsd-admin must be executed under pkexec");
 
+  errno = 0;
   uid = strtol (pkexec_uid, NULL, 10);
-  if ((errno == ERANGE && (uid == LONG_MAX || uid == LONG_MIN))
-      || (errno != 0 && uid == 0))
+  if (errno != 0)
     g_error ("Unable to convert PKEXEC_UID string to uid_t");
 
   context = g_option_context_new (NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]