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

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