From bdfeddd3a385e0d09d98cc5b70433702f4af2f64 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 9 Apr 2018 16:10:43 -0700 Subject: [PATCH] Add strncpy to the list of banned functions strncpy does not guarantee that the resulting strings are null terminated, which leads to mistakes. It's always better to use a function like snprintf instead, so ban it. Change-Id: I6ca56103a35df3364a04bdd68937768bc0479235 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/407027 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- scripts/check_format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 2e841ef46..5d1e8070c 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -77,7 +77,7 @@ rm -f whitespace.log echo -n "Checking for use of forbidden library functions..." -git grep --line-number -w '\(strcpy\|sprintf\|vsprintf\)' -- './*.c' ':!lib/vhost/rte_vhost*/**' > badfunc.log || true +git grep --line-number -w '\(strncpy\|strcpy\|sprintf\|vsprintf\)' -- './*.c' ':!lib/vhost/rte_vhost*/**' > badfunc.log || true if [ -s badfunc.log ]; then echo " Forbidden library functions detected" cat badfunc.log