aboutsummaryrefslogtreecommitdiffstats
path: root/mount.cifs.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2011-04-15 07:49:51 -0400
committerJeff Layton <jlayton@samba.org>2011-04-15 07:49:51 -0400
commit00e7fcbe9f519a8251707321eadd34cf156447e5 (patch)
tree8cd13626dd3203267354f825d39e33f59d159efd /mount.cifs.c
parentffac601c45b167a1af1d35561f1c01ab0813cc14 (diff)
downloadcifs-utils-00e7fcbe9f519a8251707321eadd34cf156447e5.tar.gz
cifs-utils-00e7fcbe9f519a8251707321eadd34cf156447e5.tar.xz
cifs-utils-00e7fcbe9f519a8251707321eadd34cf156447e5.zip
mount.cifs: fix test for strtoul failure in mount.cifs
It currently test to see if errno == -EINVAL and whether the endptr is '\0'. That's not correct however. What we really want it to do is check to see if any error occurred by setting errno to 0 before the conversion. If one did, then try to treat the value as a name. Also fix a bogus compiler warning about cruid being uninitialized. Reported-by: Jian Li <jiali@redhat.com> Signed-off-by: Jeff Layton <jlayton@samba.org>
Diffstat (limited to 'mount.cifs.c')
-rw-r--r--mount.cifs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mount.cifs.c b/mount.cifs.c
index 29b0d4c..9d7e107 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -861,7 +861,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
int got_uid = 0;
int got_cruid = 0;
int got_gid = 0;
- uid_t uid, cruid;
+ uid_t uid, cruid = 0;
gid_t gid;
char *ep;
struct passwd *pw;
@@ -1031,8 +1031,9 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
goto nocopy;
got_uid = 1;
+ errno = 0;
uid = strtoul(value, &ep, 10);
- if (errno != EINVAL && *ep == '\0')
+ if (errno == 0)
goto nocopy;
pw = getpwnam(value);
@@ -1049,8 +1050,9 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
goto nocopy;
got_cruid = 1;
+ errno = 0;
cruid = strtoul(value, &ep, 10);
- if (errno != EINVAL && *ep == '\0')
+ if (errno == 0)
goto nocopy;
pw = getpwnam(value);
@@ -1066,8 +1068,9 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
goto nocopy;
got_gid = 1;
+ errno = 0;
gid = strtoul(value, &ep, 10);
- if (errno != EINVAL && *ep == '\0')
+ if (errno == 0)
goto nocopy;
gr = getgrnam(value);