From e40787da7188083075ca2f0dc7e947a569b228e7 Mon Sep 17 00:00:00 2001 From: mxms Date: Thu, 9 Oct 2025 16:37:22 +0000 Subject: [PATCH] Add WEBP_UNSAFE_MEMCMP helper Memcmp is used in other parts of libwebp which we didn't see yet in webputils. The places that use memcp use it as an expression, (i.e. if (memcmp(...)), so explicitly do not wrap in do { } while (0) guard. Change-Id: Ifa972640bae052717a1af02112c62dc197dfe0f1 --- src/utils/bounds_safety.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/bounds_safety.h b/src/utils/bounds_safety.h index ccc89419..51844d0b 100644 --- a/src/utils/bounds_safety.h +++ b/src/utils/bounds_safety.h @@ -87,6 +87,10 @@ WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(uint8_t*, src, size), size); \ } while (0) +#define WEBP_UNSAFE_MEMCMP(s1, s2, size) \ + memcmp(WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(uint8_t*, s1, size), \ + WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(uint8_t*, s2, size), size) + #else // WEBP_SUPPORT_FBOUNDS_SAFETY #define WEBP_ASSUME_UNSAFE_INDEXABLE_ABI @@ -105,6 +109,7 @@ #define WEBP_UNSAFE_MEMCPY(dst, src, size) memcpy(dst, src, size) #define WEBP_UNSAFE_MEMSET(dst, c, size) memset(dst, c, size) #define WEBP_UNSAFE_MEMMOVE(dst, src, size) memmove(dst, src, size) +#define WEBP_UNSAFE_MEMCMP(s1, s2, size) memcmp(s1, s2, size) #define WEBP_UNSAFE_FORGE_SINGLE(typ, ptr) ((typ)(ptr)) #define WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(typ, ptr, size) ((typ)(ptr))