Blame SOURCES/autofs-5.1.0-fix-some-out-of-order-evaluations-in-parse_amd_c.patch

306fa1
autofs-5.1.0 - fix some out of order evaluations in parse_amd.c
306fa1
306fa1
From: Ian Kent <ikent@redhat.com>
306fa1
306fa1
Fix some check contents before NULL check ordering in modules/parse_amd.c.
306fa1
---
306fa1
 CHANGELOG           |    1 +
306fa1
 modules/parse_amd.c |   33 ++++++++++++++-------------------
306fa1
 2 files changed, 15 insertions(+), 19 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -142,6 +142,7 @@
306fa1
 - add return check in ldap check_map_indirect().
306fa1
 - check host macro is set before use.
306fa1
 - check options length before use in parse_amd.c.
306fa1
+- fix some out of order evaluations in parse_amd.c.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/parse_amd.c
306fa1
+++ autofs-5.0.7/modules/parse_amd.c
306fa1
@@ -1226,13 +1226,12 @@ static unsigned int validate_auto_option
306fa1
 	 * left blank the mount must be expected to fail so don't
306fa1
 	 * report the error.
306fa1
 	 */
306fa1
-	if (!*entry->fs)
306fa1
-		return 0;
306fa1
-	else if (!entry->fs) {
306fa1
+	if (!entry->fs) {
306fa1
 		error(logopt, MODPREFIX
306fa1
 		      "%s: file system not given", entry->type);
306fa1
 		return 0;
306fa1
-	}
306fa1
+	} else if (!*entry->fs)
306fa1
+		return 0;
306fa1
 	return 1;
306fa1
 }
306fa1
 
306fa1
@@ -1255,13 +1254,12 @@ static unsigned int validate_nfs_options
306fa1
 	 * expected to fail.
306fa1
 	 */
306fa1
 	if (!entry->rfs || !*entry->rfs) {
306fa1
-		if (!*entry->rfs)
306fa1
+		if (entry->rfs && !*entry->rfs)
306fa1
 			return 0;
306fa1
 		/* Map option fs has been intentionally left blank */
306fa1
 		if (entry->fs && !*entry->fs)
306fa1
 			return 0;
306fa1
-		if (entry->fs)
306fa1
-			entry->rfs = strdup(entry->fs);
306fa1
+		entry->rfs = strdup(entry->fs);
306fa1
 		if (!entry->rfs) {
306fa1
 			error(logopt, MODPREFIX
306fa1
 			      "%s: remote file system not given", entry->type);
306fa1
@@ -1285,24 +1283,22 @@ static unsigned int validate_generic_opt
306fa1
 	 * expected to fail so don't report the error.
306fa1
 	 */
306fa1
 	if (fstype != AMD_MOUNT_TYPE_LOFS) {
306fa1
-		if (!*entry->dev)
306fa1
-			return 0;
306fa1
-		else if (!entry->dev) {
306fa1
+		if (!entry->dev) {
306fa1
 			error(logopt, MODPREFIX
306fa1
 			      "%s: mount device not given", entry->type);
306fa1
 			return 0;
306fa1
-		}
306fa1
-	} else {
306fa1
-		if (!*entry->rfs)
306fa1
+		} else if (!*entry->dev)
306fa1
 			return 0;
306fa1
-		else if (!entry->rfs) {
306fa1
+	} else {
306fa1
+		if (!entry->rfs) {
306fa1
 			/*
306fa1
 			 * Can't use entry->type as the mount type to reprot
306fa1
 			 * the error since entry->type == "bind" not "lofs".
306fa1
 			 */
306fa1
 			error(logopt, "lofs: mount device not given");
306fa1
 			return 0;
306fa1
-		}
306fa1
+		} else if (!*entry->rfs)
306fa1
+			return 0;
306fa1
 	}
306fa1
 	if (entry->sublink && !entry->fs) {
306fa1
 		error(logopt, MODPREFIX
306fa1
@@ -1337,13 +1333,12 @@ static unsigned int validate_host_option
306fa1
 	 * if it isn't given in the map entry. Don't report an error
306fa1
 	 * if it has been left empty since it's expected to fail.
306fa1
 	 */
306fa1
-	if (!*entry->rhost)
306fa1
-		return 0;
306fa1
-	else if (!entry->rhost) {
306fa1
+	if (!entry->rhost) {
306fa1
 		error(logopt, MODPREFIX
306fa1
 		      "%s: remote host name not given", entry->type);
306fa1
 		return 0;
306fa1
-	}
306fa1
+	} else if (!*entry->rhost)
306fa1
+		return 0;
306fa1
 	return 1;
306fa1
 }
306fa1