diff options
author | José Bollo <jose.bollo@open.eurogiciel.org> | 2014-01-20 15:58:20 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@open.eurogiciel.org> | 2014-01-20 15:58:20 +0100 |
commit | 9c9a8ade39bddd416683410acbb5bdbc0ea2f23d (patch) | |
tree | a874e71fcce307a339f6ade6415d12361911adcc | |
parent | 6f9f9e5f8a42883973889da883bdc72b03df783a (diff) | |
download | vconf-9c9a8ade39bddd416683410acbb5bdbc0ea2f23d.tar.gz vconf-9c9a8ade39bddd416683410acbb5bdbc0ea2f23d.tar.bz2 vconf-9c9a8ade39bddd416683410acbb5bdbc0ea2f23d.zip |
Fix a bug in search of keys
The function '_vconf_keylist_lookup' coulded return a node
that was not matching the requested 'keyname'. For example,
searching the key "acl" in a list containing "aclxxxx", "acl"
would return the node "aclxxx" instead of "acl".
Also compute the length to be compared only one time, not
at each turn of the loop.
Change-Id: Id26e9d0eace311e5537fbce075f912d0a263f31d
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
-rwxr-xr-x | vconf.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -156,6 +156,7 @@ static keynode_t *_vconf_keylist_lookup(keylist_t *keylist, const char *keyname, keynode_t **before_keynode) { keynode_t *found_node, *temp_node = NULL; + size_t length = 1 + strlen(keyname); found_node = _vconf_keylist_headnode(keylist); @@ -165,7 +166,7 @@ static keynode_t *_vconf_keylist_lookup(keylist_t *keylist, const char *keyname, return NULL; } - if (!strncmp(keyname, found_node->keyname, strlen(keyname))) { + if (!memcmp(keyname, found_node->keyname, length)) { if (before_keynode) { *before_keynode = temp_node; } |