* [PATCH] fix bug in name_list_key_add()
@ 2008-09-05 13:49 Alan Jenkins
2008-09-08 19:52 ` Kay Sievers
0 siblings, 1 reply; 2+ messages in thread
From: Alan Jenkins @ 2008-09-05 13:49 UTC (permalink / raw)
To: linux-hotplug
The search for an existing key e.g. FOO would match longer keys e.g. FOOBAR.
Reuse the correct code from name_list_remove().
diff --git a/udev/udev_utils.c b/udev/udev_utils.c
index f63a9fa..9b6ba24 100644
--- a/udev/udev_utils.c
+++ b/udev/udev_utils.c
@@ -89,14 +89,17 @@ struct name_entry *name_list_key_add(struct list_head *name_list, const char *ke
{
struct name_entry *name_loop;
struct name_entry *name_new;
+ size_t keylen = strlen(key);
list_for_each_entry(name_loop, name_list, node) {
- if (strncmp(name_loop->name, key, strlen(key)) = 0) {
- dbg("key already present '%s', replace it\n", name_loop->name);
- snprintf(name_loop->name, sizeof(name_loop->name), "%s=%s", key, value);
- name_loop->name[sizeof(name_loop->name)-1] = '\0';
- return name_loop;
- }
+ if (strncmp(name_loop->name, key, keylen) != 0)
+ continue;
+ if (name_loop->name[keylen] != '=')
+ continue;
+ dbg("key already present '%s', replace it\n", name_loop->name);
+ snprintf(name_loop->name, sizeof(name_loop->name), "%s=%s", key, value);
+ name_loop->name[sizeof(name_loop->name)-1] = '\0';
+ return name_loop;
}
name_new = malloc(sizeof(struct name_entry));
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fix bug in name_list_key_add()
2008-09-05 13:49 [PATCH] fix bug in name_list_key_add() Alan Jenkins
@ 2008-09-08 19:52 ` Kay Sievers
0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2008-09-08 19:52 UTC (permalink / raw)
To: linux-hotplug
On Fri, Sep 5, 2008 at 15:49, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
> The search for an existing key e.g. FOO would match longer keys e.g. FOOBAR.
> Reuse the correct code from name_list_remove().
Applied.
Thanks,
Kay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-09-08 19:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-05 13:49 [PATCH] fix bug in name_list_key_add() Alan Jenkins
2008-09-08 19:52 ` Kay Sievers
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).