diff options
author | Max Kellermann <max@duempel.org> | 2009-03-27 19:36:24 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-27 19:36:24 +0100 |
commit | 86827fc63e94997b1c5f2e9e966962473acc9694 (patch) | |
tree | 09c329123e2edb002440c05366d5574f2dcacab6 /src | |
parent | 51894725ec02dd796878414168c25857e2e0b95a (diff) | |
download | mpd-86827fc63e94997b1c5f2e9e966962473acc9694.tar.gz mpd-86827fc63e94997b1c5f2e9e966962473acc9694.tar.xz mpd-86827fc63e94997b1c5f2e9e966962473acc9694.zip |
tag_pool: use memcmp() instead of strcmp() for non-terminated string
The strings passed to tag_pool_get_item() are not null-terminated, and
the caller passes the string length. Don't assume it is
null-terminated anyway by using strcmp().
Diffstat (limited to '')
-rw-r--r-- | src/tag_pool.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tag_pool.c b/src/tag_pool.c index fb59669e6..6aef12941 100644 --- a/src/tag_pool.c +++ b/src/tag_pool.c @@ -101,7 +101,9 @@ tag_pool_get_item(enum tag_type type, const char *value, size_t length) slot_p = &slots[calc_hash_n(type, value, length) % NUM_SLOTS]; for (slot = *slot_p; slot != NULL; slot = slot->next) { if (slot->item.type == type && - strcmp(value, slot->item.value) == 0 && slot->ref < 0xff) { + length == strlen(slot->item.value) && + memcmp(value, slot->item.value, length) == 0 && + slot->ref < 0xff) { assert(slot->ref > 0); ++slot->ref; return &slot->item; |