<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">autofs-5.1.0 - fix some out of order evaluations in parse_amd.c

From: Ian Kent &lt;ikent@redhat.com&gt;

Fix some check contents before NULL check ordering in modules/parse_amd.c.
---
 CHANGELOG           |    1 +
 modules/parse_amd.c |   33 ++++++++++++++-------------------
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 81aadca..4e00929 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
 - add return check in ldap check_map_indirect().
 - check host macro is set before use.
 - check options length before use in parse_amd.c.
+- fix some out of order evaluations in parse_amd.c.
 
 04/06/2014 autofs-5.1.0
 =======================
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 6764152..c4992c1 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1226,13 +1226,12 @@ static unsigned int validate_auto_options(unsigned int logopt,
 	 * left blank the mount must be expected to fail so don't
 	 * report the error.
 	 */
-	if (!*entry-&gt;fs)
-		return 0;
-	else if (!entry-&gt;fs) {
+	if (!entry-&gt;fs) {
 		error(logopt, MODPREFIX
 		      "%s: file system not given", entry-&gt;type);
 		return 0;
-	}
+	} else if (!*entry-&gt;fs)
+		return 0;
 	return 1;
 }
 
@@ -1255,13 +1254,12 @@ static unsigned int validate_nfs_options(unsigned int logopt,
 	 * expected to fail.
 	 */
 	if (!entry-&gt;rfs || !*entry-&gt;rfs) {
-		if (!*entry-&gt;rfs)
+		if (entry-&gt;rfs &amp;&amp; !*entry-&gt;rfs)
 			return 0;
 		/* Map option fs has been intentionally left blank */
 		if (entry-&gt;fs &amp;&amp; !*entry-&gt;fs)
 			return 0;
-		if (entry-&gt;fs)
-			entry-&gt;rfs = strdup(entry-&gt;fs);
+		entry-&gt;rfs = strdup(entry-&gt;fs);
 		if (!entry-&gt;rfs) {
 			error(logopt, MODPREFIX
 			      "%s: remote file system not given", entry-&gt;type);
@@ -1285,24 +1283,22 @@ static unsigned int validate_generic_options(unsigned int logopt,
 	 * expected to fail so don't report the error.
 	 */
 	if (fstype != AMD_MOUNT_TYPE_LOFS) {
-		if (!*entry-&gt;dev)
-			return 0;
-		else if (!entry-&gt;dev) {
+		if (!entry-&gt;dev) {
 			error(logopt, MODPREFIX
 			      "%s: mount device not given", entry-&gt;type);
 			return 0;
-		}
-	} else {
-		if (!*entry-&gt;rfs)
+		} else if (!*entry-&gt;dev)
 			return 0;
-		else if (!entry-&gt;rfs) {
+	} else {
+		if (!entry-&gt;rfs) {
 			/*
 			 * Can't use entry-&gt;type as the mount type to reprot
 			 * the error since entry-&gt;type == "bind" not "lofs".
 			 */
 			error(logopt, "lofs: mount device not given");
 			return 0;
-		}
+		} else if (!*entry-&gt;rfs)
+			return 0;
 	}
 	if (entry-&gt;sublink &amp;&amp; !entry-&gt;fs) {
 		error(logopt, MODPREFIX
@@ -1337,13 +1333,12 @@ static unsigned int validate_host_options(unsigned int logopt,
 	 * if it isn't given in the map entry. Don't report an error
 	 * if it has been left empty since it's expected to fail.
 	 */
-	if (!*entry-&gt;rhost)
-		return 0;
-	else if (!entry-&gt;rhost) {
+	if (!entry-&gt;rhost) {
 		error(logopt, MODPREFIX
 		      "%s: remote host name not given", entry-&gt;type);
 		return 0;
-	}
+	} else if (!*entry-&gt;rhost)
+		return 0;
 	return 1;
 }
 
</pre></body></html>