From patchwork Fri Apr 15 11:25:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 710651 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3FBPtvh019407 for ; Fri, 15 Apr 2011 11:25:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755921Ab1DOLZz (ORCPT ); Fri, 15 Apr 2011 07:25:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34951 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755905Ab1DOLZz (ORCPT ); Fri, 15 Apr 2011 07:25:55 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3FBPs09018551 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Apr 2011 07:25:54 -0400 Received: from tlielax.poochiereds.net (vpn-8-217.rdu.redhat.com [10.11.8.217]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3FBPsHA031708 for ; Fri, 15 Apr 2011 07:25:54 -0400 From: Jeff Layton To: linux-cifs@vger.kernel.org Subject: [PATCH] mount.cifs: fix test for strtoul failure in mount.cifs Date: Fri, 15 Apr 2011 07:25:53 -0400 Message-Id: <1302866753-7887-1-git-send-email-jlayton@samba.org> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Apr 2011 11:25:59 +0000 (UTC) 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. Signed-off-by: Jeff Layton --- mount.cifs.c | 11 +++++++---- 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);