Check that max parameters length is multiple of sizeof(int32) (#6253)

This commit is contained in:
Olek
2026-01-21 17:22:47 -05:00
committed by GitHub
parent 8c3544a58c
commit fd1cb318e3

View File

@@ -118,15 +118,18 @@ locateField(STObject const& obj, Slice const& locator)
if (locator.empty() || (locator.size() & 3)) // must be multiple of 4
return Unexpected(HostFunctionError::LOCATOR_MALFORMED);
static_assert(maxWasmParamLength % sizeof(int32_t) == 0);
int32_t locBuf[maxWasmParamLength / sizeof(int32_t)];
int32_t const* locPtr = &locBuf[0];
int32_t const locSize = locator.size() / sizeof(int32_t);
uintptr_t p = reinterpret_cast<uintptr_t>(locator.data());
if (p & (alignof(int32_t) - 1)) // unaligned
memcpy(&locBuf[0], locator.data(), locator.size());
else
locPtr = reinterpret_cast<int32_t const*>(locator.data());
{
uintptr_t const p = reinterpret_cast<uintptr_t>(locator.data());
if (p & (alignof(int32_t) - 1)) // unaligned
memcpy(&locBuf[0], locator.data(), locator.size());
else
locPtr = reinterpret_cast<int32_t const*>(locator.data());
}
STBase const* field = nullptr;
auto const& knownSFields = SField::getKnownCodeToField();