test: remove all uses of strcpy in the code

Then also add a check in check_format.sh and fail if
a new instance is found again.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia35c343e1b7bb44b3b5f4f8484adb9e0d5702d67
Reviewed-on: https://review.gerrithub.io/390916
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2017-12-07 17:18:21 -07:00
parent dbe275e35a
commit 474fcf64b2
3 changed files with 17 additions and 3 deletions
scripts
test/unit/lib
iscsi/param.c
jsonrpc/jsonrpc_server.c

@ -51,6 +51,19 @@ else
fi
rm -f comment.log
echo -n "Checking for use of forbidden library functions..."
git grep -w strcpy -- app examples lib test > badfunc.log || true
if [ -s badfunc.log ]; then
echo " Forbidden library functions detected"
cat badfunc.log
rc=1
else
echo " OK"
fi
rm -f badfunc.log
echo -n "Checking blank lines at end of file..."
if ! git grep -I -l -e . -z | \

@ -240,7 +240,7 @@ parse_valid_test(void)
data = malloc(len);
SPDK_CU_ASSERT_FATAL(data != NULL);
memset(data, 'A', len);
strcpy(data, "CHAP_C");
memcpy(data, "CHAP_C", 6);
data[6] = '=';
data[len - 1] = '\0';
rc = spdk_iscsi_parse_params(&params, data, len, false, NULL);
@ -315,7 +315,7 @@ parse_invalid_test(void)
data = malloc(len);
SPDK_CU_ASSERT_FATAL(data != NULL);
memset(data, 'A', len);
strcpy(data, "CHAP_C");
memcpy(data, "CHAP_C", 6);
data[6] = '=';
data[len - 1] = '\0';
rc = spdk_iscsi_parse_params(&params, data, len, false, NULL);

@ -361,7 +361,8 @@ test_parse_request_streaming(void)
FREE_REQUEST();
/* Partial (but not invalid) requests - parse should not consume anything. */
strcpy(g_buf, "{\"jsonrpc\":\"2.0\",\"method\":\"b\",\"params\":[2],\"id\":2}");
snprintf(g_buf, sizeof(g_buf), "%s",
"{\"jsonrpc\":\"2.0\",\"method\":\"b\",\"params\":[2],\"id\":2}");
len = strlen(g_buf);
/* Try every partial length up to the full request length */