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

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