From f40c3e98259fa751b84e39c5a26ae37ca48a2e18 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 6 Apr 2018 11:45:19 -0700 Subject: [PATCH] check_format: add [v]sprintf() to banned functions Fix up the single instance in the tree (dmaperf.c example) and disallow more string functions with no destination buffer size. Change-Id: I2bd39d6e848cd8a13536e26c4f0ee6713cf6dff9 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/406829 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- examples/ioat/kperf/kmod/dmaperf.c | 2 +- scripts/check_format.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ioat/kperf/kmod/dmaperf.c b/examples/ioat/kperf/kmod/dmaperf.c index 4892c27e3..430adde00 100644 --- a/examples/ioat/kperf/kmod/dmaperf.c +++ b/examples/ioat/kperf/kmod/dmaperf.c @@ -605,7 +605,7 @@ static int perf_debugfs_setup(struct perf_ctx *perf) for (i = 0; i < MAX_THREADS; i++) { struct pthr_ctx *pctx = &perf->pthr_ctx[i]; - sprintf(temp_name, "thread_%d", i); + snprintf(temp_name, sizeof(temp_name), "thread_%d", i); pctx->debugfs_thr_dir = debugfs_create_dir(temp_name, perf->debugfs_node_dir); if (!pctx->debugfs_thr_dir) { diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 2c7badc17..edea664a9 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 -w strcpy -- app examples lib test > badfunc.log || true +git grep -w '\(strcpy\|sprintf\|vsprintf\)' -- app examples lib test > badfunc.log || true if [ -s badfunc.log ]; then echo " Forbidden library functions detected"