[dpdk-dev] [PATCH 06/11] kvargs: simpler parsing and allow duplicated keys

Olivier MATZ olivier.matz at 6wind.com
Wed Jan 29 23:17:34 CET 2014

Hi Bruce,

>> Also replace rte_strsplit() by more a standard function strtok_r() that is
>> easier to understand for people already knowing the libc. It also avoids
>> useless calls to strnlen(). The delimiters macros become strings instead of
>> chars due to the strtok_r() API.
> As a general rule, we try to use only string functions which
> track the buffer length they are working with, which is why the
> function rte_strsplit() is used. While strtok_r() is indeed a
> standard C function, why not use the code as originally written?

Thank you for your comment.

Another reason for not using rte_strsplit() is that the buffer length
argument that was given was not relevant. Indeed, the string we want to
parse initially comes from the command line arguments, which is
duplicated with strdup(). It is not stored in a fixed size buffer.

In my opinion, giving strnlen(pairs[i], MAX_ARG_STRLEN) as the size
to rte_strsplit() would not prevent the program to a segfault or to
read a corrupted string if it is not properly null-terminated.

Does it makes sense ?


More information about the dev mailing list