Description: Fix backend matcher.
 Should be fixed in Upstream as well.
Author: Simon Effenberg <seffenberg@team.mobile.de>
Last-Update: 2013-03-27
--- a/bin/varnishd/cache_backend_cfg.c
+++ b/bin/varnishd/cache_backend_cfg.c
@@ -382,15 +382,15 @@
 	}
 	VTAILQ_FOREACH(b, &backends, list) {
 		CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
-		if (port_b != NULL && strncmp(b->port, port_b, port_l) != 0)
+		if (port_b != NULL && (strlen(b->port) != port_l || strncmp(b->port, port_b, port_l) != 0))
 			continue;
-		if (name_b != NULL && strncmp(b->vcl_name, name_b, name_l) != 0)
+		if (name_b != NULL && (strlen(b->vcl_name) != name_l || strncmp(b->vcl_name, name_b, name_l) != 0))
 			continue;
 		if (ip_b != NULL &&
 		    (b->ipv4_addr == NULL ||
-		      strncmp(b->ipv4_addr, ip_b, ip_l)) &&
+		      strlen(b->ipv4_addr) != ip_l || strncmp(b->ipv4_addr, ip_b, ip_l) != 0) &&
 		    (b->ipv6_addr == NULL ||
-		      strncmp(b->ipv6_addr, ip_b, ip_l)))
+		      strlen(b->ipv6_addr) != ip_l || strncmp(b->ipv6_addr, ip_b, ip_l) != 0))
 			continue;
 		found++;
 		i = func(cli, b, priv);
