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-28 15:29:12 +0200
commitddc1b701f929e47397abcea058505fec1298ef10 (patch)
tree6f5264c10c20737c745e3b2edd3872a3c3a174e4
parent8109332b586add3544e91efcc5d7c7474c00bc0b (diff)
downloadgvfs-ddc1b701f929e47397abcea058505fec1298ef10.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);