Blob Blame History Raw
commit 845c87b67b7bfd60127e23d1df93a94ceb9d3d18
Author: NeilBrown <neilb@suse.com>
Date:   Wed Jul 26 13:51:51 2017 -0400

    mount: Fix problems with parsing minorversion=
    
    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 <neilb@suse.com>
    Signed-off-by: Steve Dickson <steved@redhat.com>
    (cherry picked from commit 050153ef6a86ff5ab06ef65be36336824a323779)

diff --git a/utils/mount/network.c b/utils/mount/network.c
index b2e4374..b64c526 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -1283,13 +1283,19 @@ nfs_nfs_version(struct mount_options *options, struct nfs_version *version)
 	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 (version->major < 4)
+	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;
-
-	if (*cptr == '.') {
+	} else if (version->major < 4)
+		version->v_mode = V_SPECIFIC;
+	else if (*cptr == '.') {
 		version_val = ++cptr;
 		if (!(version->minor = strtol(version_val, &cptr, 10)) && cptr == version_val)
 			goto ret_error;
@@ -1303,7 +1309,10 @@ nfs_nfs_version(struct mount_options *options, struct nfs_version *version)
 	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 ) {