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

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