[master] 0fa4baead Using memcpy() in bstrcpy() confused FlexeLint, use strcpy() instead.

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 21 08:34:07 UTC 2019


commit 0fa4baead49f0a45f68d3db0b7743c5e4e93ad4d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 21 08:14:20 2019 +0000

    Using memcpy() in bstrcpy() confused FlexeLint, use strcpy() instead.

diff --git a/include/vdef.h b/include/vdef.h
index dc622e273..6781026ef 100644
--- a/include/vdef.h
+++ b/include/vdef.h
@@ -59,9 +59,8 @@
 /* Safe strcpy into a fixed-size buffer */
 #define bstrcpy(dst, src)						\
 	do {								\
-		size_t lbstrcpy = strlen(src) + 1;			\
-		assert(lbstrcpy <= sizeof dst);				\
-		memcpy(dst, src, lbstrcpy);				\
+		assert(strlen(src) + 1 <= sizeof (dst));		\
+		strcpy((dst), (src));					\
 	} while (0)
 
 // TODO #define strcpy BANNED


More information about the varnish-commit mailing list