From patchwork Thu Jul 13 06:30:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9837773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C6F160392 for ; Thu, 13 Jul 2017 06:30:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CB05283E7 for ; Thu, 13 Jul 2017 06:30:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 315972866B; Thu, 13 Jul 2017 06:30:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C735D283E7 for ; Thu, 13 Jul 2017 06:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751106AbdGMGav (ORCPT ); Thu, 13 Jul 2017 02:30:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:47504 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751067AbdGMGau (ORCPT ); Thu, 13 Jul 2017 02:30:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9E92AAB9B; Thu, 13 Jul 2017 06:30:48 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Thu, 13 Jul 2017 16:30:05 +1000 Subject: [PATCH 4/4] mount: Fix problems with parsing minorversion= Cc: linux-nfs@vger.kernel.org Message-ID: <149992740578.9181.10837920531865843446.stgit@noble> In-Reply-To: <149992731965.9181.6611555845253022123.stgit@noble> References: <149992731965.9181.6611555845253022123.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1/ minorversion=0 is not recognized, as errors from strtol() are not correctly detected. 2/ when there is an error in the minorversion= value, no message is presented. 3/ Current code recognizes "minorversion" and sets V_SPECIFIC, but then because *cptr == '\0', the v_mode is reset to V_GENERAL. This results in minorversion negotiation, which is not wanted. This patch addresses all of these. Signed-off-by: NeilBrown --- utils/mount/network.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/utils/mount/network.c b/utils/mount/network.c index d673391b5fff..11ee818f9705 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -100,7 +100,6 @@ static const char *nfs_version_opttbl[] = { "v4", "vers", "nfsvers", - "minorversion", NULL, }; @@ -1291,17 +1290,19 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v if (!version_val) goto ret_error; - if (!(version->major = strtol(version_val, &cptr, 10))) + version->major = strtol(version_val, &cptr, 10); + if (cptr == version_val || (*cptr && *cptr != '.')) goto ret_error; - - if (strcmp(nfs_version_opttbl[i], "minorversion") == 0) { + if (version->major == 4 && *cptr != '.' && + (version_val = po_get(options, "minorversion")) != NULL) { + version->minor = strtol(version_val, &cptr, 10); + i = -1; + if (*cptr) + goto ret_error; version->v_mode = V_SPECIFIC; - version->minor = version->major; - version->major = 4; } else if (version->major < 4) version->v_mode = V_SPECIFIC; - - if (*cptr == '.') { + else if (*cptr == '.') { version_val = ++cptr; if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val) goto ret_error; @@ -1315,7 +1316,10 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v return 1; ret_error: - if (i <= 2 ) { + if (i < 0) { + nfs_error(_("%s: parsing error on 'minorversion=' option"), + progname); + } else if (i <= 2 ) { nfs_error(_("%s: parsing error on 'v' option"), progname); } else if (i == 3 ) {