kvargs: fix buffer overflow when parsing list
authorYunjian Wang <wangyunjian@huawei.com>
Fri, 27 Mar 2020 08:09:55 +0000 (09:09 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 27 Mar 2020 16:03:46 +0000 (17:03 +0100)
commitffcf831454a93c1da54299d4066dd03de6712a9b
treec9f7f2e9dc7f9500a6b684c98e0df913d971c0b2
parent4bf2b36fd14da74f5dd5c111501698a5b7cb0f6d
kvargs: fix buffer overflow when parsing list

When the input string is "key=[", the ending '\0' is replaced
by a ',', leading to a heap buffer overflow.

Check the content of ctx1 to avoid this problem.

Fixes: cc0579f2339a ("kvargs: support list value")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
app/test/test_kvargs.c
lib/librte_kvargs/rte_kvargs.c