From 1532983fb5755305a86fc37d2f35a7757d2bd66f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 24 Apr 2020 16:15:51 +0200 Subject: [PATCH] tag/Pool: use strncmp() without strlen() to compare strings --- src/tag/Pool.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tag/Pool.cxx b/src/tag/Pool.cxx index 5e2af0c79..83014c3b6 100644 --- a/src/tag/Pool.cxx +++ b/src/tag/Pool.cxx @@ -114,7 +114,10 @@ tag_pool_get_item(TagType type, StringView value) noexcept auto slot_p = tag_value_slot_p(type, value); for (auto slot = *slot_p; slot != nullptr; slot = slot->next) { if (slot->item.type == type && - value.Equals(slot->item.value) && + /* strncmp() only works if there are no null + bytes, which FixTagString() has already ensured + at this point */ + strncmp(value.data, slot->item.value, value.size) == 0 && slot->ref < TagPoolSlot::MAX_REF) { assert(slot->ref > 0); ++slot->ref;