Blame SOURCES/autofs-5.0.7-fix-host_addr-null-reference-in-add_new_host.patch

306fa1
autofs-5.0.7 - fix host_addr null reference in add_new_host()
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The function add_new_host() is always called from a loop that depends
306fa1
on host_addr being non-null.
306fa1
306fa1
Remove the redundant check.
306fa1
---
306fa1
 modules/replicated.c |   29 ++++++++++-------------------
306fa1
 1 file changed, 10 insertions(+), 19 deletions(-)
306fa1
306fa1
diff --git a/modules/replicated.c b/modules/replicated.c
306fa1
index 0a044b9..e793ca4 100644
306fa1
--- a/modules/replicated.c
306fa1
+++ b/modules/replicated.c
306fa1
@@ -1030,28 +1030,19 @@ static int add_new_host(struct host **list,
306fa1
 	unsigned int prx;
306fa1
 	int addr_len;
306fa1
 
306fa1
+	prx = get_proximity(host_addr->ai_addr);
306fa1
+
306fa1
 	/*
306fa1
-	 * If we are using random selection we pretend all hosts are at
306fa1
-	 * the same proximity so hosts further away don't get excluded.
306fa1
-	 * We can't use PROXIMITY_LOCAL or we won't perform an RPC ping
306fa1
-	 * to remove hosts that may be down.
306fa1
+	 * If we want the weight to be the determining factor
306fa1
+	 * when selecting a host, or we are using random selection,
306fa1
+	 * then all hosts must have the same proximity. However,
306fa1
+	 * if this is the local machine it should always be used
306fa1
+	 * since it is certainly available.
306fa1
 	 */
306fa1
-	if (!host_addr)
306fa1
+	if (prx != PROXIMITY_LOCAL &&
306fa1
+	   (options & (MOUNT_FLAG_USE_WEIGHT_ONLY |
306fa1
+		       MOUNT_FLAG_RANDOM_SELECT)))
306fa1
 		prx = PROXIMITY_SUBNET;
306fa1
-	else {
306fa1
-		prx = get_proximity(host_addr->ai_addr);
306fa1
-		/*
306fa1
-		 * If we want the weight to be the determining factor
306fa1
-		 * when selecting a host, or we are using random selection,
306fa1
-		 * then all hosts must have the same proximity. However,
306fa1
-		 * if this is the local machine it should always be used
306fa1
-		 * since it is certainly available.
306fa1
-		 */
306fa1
-		if (prx != PROXIMITY_LOCAL &&
306fa1
-		   (options & (MOUNT_FLAG_USE_WEIGHT_ONLY |
306fa1
-			       MOUNT_FLAG_RANDOM_SELECT)))
306fa1
-			prx = PROXIMITY_SUBNET;
306fa1
-	}
306fa1
 
306fa1
 	/*
306fa1
 	 * If we tried to add an IPv6 address and we don't have IPv6