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

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