[master] 24459e2 use snprintf() instead of strlcpy()

Poul-Henning Kamp phk at varnish-cache.org
Thu May 12 14:19:16 CEST 2011


commit 24459e2e77b111d721ee2b5fae1f0cfc0c9e3365
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu May 12 10:55:41 2011 +0000

    use snprintf() instead of strlcpy()

diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c
index bed3b99..1f529b3 100644
--- a/lib/libvarnish/tcp.c
+++ b/lib/libvarnish/tcp.c
@@ -52,9 +52,6 @@
 #include <math.h>
 
 #include "config.h"
-#ifndef HAVE_STRLCPY
-#include "compat/strlcpy.h"
-#endif
 
 #include "libvarnish.h"
 
@@ -92,8 +89,8 @@ TCP_name(const struct sockaddr_storage *addr, unsigned l,
 		 * for the gai_strerror in the bufffer :-(
 		 */
 		printf("getnameinfo = %d %s\n", i, gai_strerror(i));
-		strlcpy(abuf, "Conversion", alen);
-		strlcpy(pbuf, "Failed", plen);
+		snprintf(abuf, alen, "Conversion");
+		snprintf(pbuf, plen, "Failed");
 		return;
 	}
 	/* XXX dirty hack for v4-to-v6 mapped addresses */
@@ -128,8 +125,8 @@ TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen)
 	if (!getpeername(sock, (void*)&addr_s, &l))
 		TCP_name(&addr_s, l, abuf, alen, pbuf, plen);
 	else {
-		strlcpy(abuf, "<none>", alen);
-		strlcpy(pbuf, "<none>", plen);
+		snprintf(abuf, alen, "<none>");
+		snprintf(pbuf, plen, "<none>");
 	}
 }
 



More information about the varnish-commit mailing list