From ddc1b701f929e47397abcea058505fec1298ef10 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 17 Mar 2017 13:34:51 +0100 Subject: 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 file 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); -- cgit v1.2.1