test/cmd_ut.c: fix cmd_ut_category
PATCH 1/1 test/cmd_ut.c: fix cmd_ut_category
In the function cmd_ut_category, the prefix is used with the function strncmp to know if the prefix should be removed from the test name, even if the prefix is NULL.
To avoid this issue, we consider that a prefix NULL mean no prefix. So we only try to remove the prefix from the test_name if the prefix is not NULL, then we avoid to call the function strncmp with a NULL prefix.
--- test/cmd_ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/cmd_ut.c +1 -1
@@ -26,7 +26,7 @@ int cmd_ut_category(const char *name, const char *prefix,const char *test_name = test->name;/* Remove the prefix */ -if (!strncmp (test_name, prefix, prefix_len)) +if (prefix && !strncmp (test_name, prefix, prefix_len)) test_name += prefix_len;if (argc >1 &&strcmp (argv[1 ], test_name))
Signature · 1 line
2.7.4
PATCH 1/1 test/cmd_ut.c: fix cmd_ut_category
Quoted 10 lines · Philippe Reynes
In the function
cmd_ut_category, the prefix is used with the function strncmp to know if the prefix should be removed from the test name, even if the prefix is NULL.To avoid this issue, we consider that a prefix NULL mean no prefix. So we only try to remove the prefix from the
test_nameif the prefix is not NULL, then we avoid to call the function strncmp with a NULL prefix.
Quoted 3 lines
Reported-by Coverity CID 281110Fixes 4ad4edfe ("cmd_ut: add a parameter prefix to the function cmd_ut_category")Signed-off-by Philippe Reynes <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200110/6a2907e6/attachment.sig>