patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] kvargs: fix a heap-buffer-overflow when detect list
@ 2020-03-19  4:38 wangyunjian
  2020-03-25 16:31 ` Olivier Matz
  2020-03-27  8:09 ` [dpdk-stable] [PATCH v2 0/3] kvargs fixes Olivier Matz
  0 siblings, 2 replies; 9+ messages in thread
From: wangyunjian @ 2020-03-19  4:38 UTC (permalink / raw)
  To: dev; +Cc: olivier.matz, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

When an input params'value is '[', leading to the 'str' over read
or heap-buffer-overflow. So we can check the 'ctx1' length to avoid
this problem.

Fixes: cc0579f2339a ("kvargs: support list value")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_kvargs/rte_kvargs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index d39332999..a1144b90b 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -48,7 +48,8 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
 		str = kvlist->pairs[i].value;
 		if (str[0] == '[') {
 			/* Find the end of the list. */
-			while (str[strlen(str) - 1] != ']') {
+			while ((str[strlen(str) - 1] != ']') &&
+			       (strlen(ctx1) > 0)) {
 				/* Restore the comma erased by strtok_r(). */
 				str[strlen(str)] = ',';
 				/* Parse until next comma. */
-- 
2.19.1



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

end of thread, other threads:[~2020-03-27 17:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19  4:38 [dpdk-stable] [dpdk-dev] [PATCH] kvargs: fix a heap-buffer-overflow when detect list wangyunjian
2020-03-25 16:31 ` Olivier Matz
2020-03-26 10:01   ` [dpdk-stable] 答复: " wangyunjian
2020-03-27  8:09 ` [dpdk-stable] [PATCH v2 0/3] kvargs fixes Olivier Matz
2020-03-27  8:09   ` [dpdk-stable] [PATCH v2 1/3] tests/kvargs: fix to consider empty elements as valid Olivier Matz
2020-03-27  8:09   ` [dpdk-stable] [PATCH v2 2/3] tests/kvargs: fix check of invalid cases Olivier Matz
2020-03-27  8:09   ` [dpdk-stable] [PATCH v2 3/3] kvargs: fix a heap buffer overflow when parsing list Olivier Matz
2020-03-27 15:16   ` [dpdk-stable] [PATCH v2 0/3] kvargs fixes David Marchand
2020-03-27 17:12     ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).