summaryrefslogtreecommitdiff
path: root/lib/librte_kvargs
diff options
context:
space:
mode:
authorOlivier Matz <olivier.matz@6wind.com>2014-01-28 17:06:40 +0100
committerDavid Marchand <david.marchand@6wind.com>2014-02-26 11:01:14 +0100
commitd24839b318676504163dd3b4e9249ff1fe61b54d (patch)
tree5918ff1318cc1f82fceae9b85795c9c0c413f35c /lib/librte_kvargs
parentac15c813157156b8651cfa5eb75c9122c6a15bbe (diff)
downloaddpdk-d24839b318676504163dd3b4e9249ff1fe61b54d.zip
dpdk-d24839b318676504163dd3b4e9249ff1fe61b54d.tar.gz
dpdk-d24839b318676504163dd3b4e9249ff1fe61b54d.tar.xz
kvargs: be strict when matching a key
When we match a key in is_valid_key() and rte_kvargs_process(), do a strict comparison (strcmp()) instead of using strstr(s1, s2) which tries a find s1 in s2. This old behavior could lead to unexpected match, for instance "cola" match "chocolate". Surprisingly, no patch was needed on rte_kvargs_count() as it already used strcmp(). Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_kvargs')
-rw-r--r--lib/librte_kvargs/rte_kvargs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index 1291084..c7f626f 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -94,9 +94,10 @@ is_valid_key(const char *valid[], const char *key_match)
{
const char **valid_ptr;
- for (valid_ptr = valid; *valid_ptr != NULL; valid_ptr++)
- if (strstr(key_match, *valid_ptr) != NULL)
+ for (valid_ptr = valid; *valid_ptr != NULL; valid_ptr++) {
+ if (strcmp(key_match, *valid_ptr) == 0)
return 1;
+ }
return 0;
}
@@ -159,7 +160,7 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
- if (strstr(pair->key, key_match) != NULL) {
+ if (strcmp(pair->key, key_match) == 0) {
if ((*handler)(pair->value, opaque_arg) < 0)
return -1;
}