summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-03-17 13:34:51 +0100
committerOndrej Holy <oholy@redhat.com>2017-03-23 11:24:16 +0100
commitb9b649e2f4d0298baabbcedf83e8f8d627c906cc (patch)
tree139d21bf22291cb7b07b75f8b1fe58c88084dc2a
parentf2f39758482a71eff4da399f47ae702ef1fa2857 (diff)
downloadgvfs-b9b649e2f4d0298baabbcedf83e8f8d627c906cc.tar.gz
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.
-rw-r--r--daemon/gvfsbackendadmin.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 4107d6f2..66c93797 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);