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

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