r1595 - trunk/varnish-cache/bin/varnishreplay

des at projects.linpro.no des at projects.linpro.no
Fri Jun 29 12:03:55 CEST 2007


Author: des
Date: 2007-06-29 12:03:55 +0200 (Fri, 29 Jun 2007)
New Revision: 1595

Modified:
   trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
Log:
Fix some style nits and an out-of-bounds array dereference.


Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c	2007-06-29 08:20:36 UTC (rev 1594)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c	2007-06-29 10:03:55 UTC (rev 1595)
@@ -119,20 +119,23 @@
  * hostname and returning a struct with necessary
  * connection info.
  */
-static struct vss_addr*
-init_connection(const char* address)
+static struct vss_addr *
+init_connection(const char *address)
 {
 	struct vss_addr **ta;
 	struct vss_addr *tap;
 	char *addr, *port;
 	int i, n;
 
-	XXXAZ(VSS_parse(address, &addr, &port));
-	XXXAN(n = VSS_resolve(addr, port, &ta));
+	if (VSS_parse(address, &addr, &port) != 0) {
+		fprintf(stderr, "Invalid address\n");
+		exit(2);
+	}
+	n = VSS_resolve(addr, port, &ta);
 	free(addr);
 	free(port);
 	if (n == 0) {
-		fprintf(stderr, "Could not open TELNET port\n");
+		fprintf(stderr, "Could not connect to server\n");
 		exit(2);
 	}
 	for (i = 1; i < n; ++i) {
@@ -174,7 +177,7 @@
 			exit(1);
 		}
 		nbuf += i;
-		if (buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n')
+		if (nbuf >= 2 && buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n')
 			break;
 
 	}




More information about the varnish-commit mailing list