All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test/cmd_ut.c: fix cmd_ut_category
@ 2020-01-09 16:34 Philippe Reynes
  2020-01-10 21:51 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Reynes @ 2020-01-09 16:34 UTC (permalink / raw)
  To: u-boot

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.

Reported-by: Coverity CID 281110
Fixes: 4ad4edfe ("cmd_ut: add a parameter prefix to the function cmd_ut_category")
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 test/cmd_ut.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 400719e..a3a9d49 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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))
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] test/cmd_ut.c: fix cmd_ut_category
  2020-01-09 16:34 [PATCH] test/cmd_ut.c: fix cmd_ut_category Philippe Reynes
@ 2020-01-10 21:51 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-01-10 21:51 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 09, 2020 at 05:34:02PM +0100, Philippe Reynes wrote:

> 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.
> 
> Reported-by: Coverity CID 281110
> Fixes: 4ad4edfe ("cmd_ut: add a parameter prefix to the function cmd_ut_category")
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-10 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 16:34 [PATCH] test/cmd_ut.c: fix cmd_ut_category Philippe Reynes
2020-01-10 21:51 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.