From a0eaf70d17d538ce4febc3dfdd2a7a429fc25f42 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 18 Jun 2026 11:03:09 -0700 Subject: [PATCH] Hardened VectorArraySet [skip ci] --- src/ivfflat.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ivfflat.h b/src/ivfflat.h index cb07e12..e0c06b7 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -309,7 +309,12 @@ VectorArrayGet(VectorArray arr, int offset) static inline void VectorArraySet(VectorArray arr, int offset, Pointer val) { - memcpy(VectorArrayGet(arr, offset), val, VARSIZE_ANY(val)); + Size size = VARSIZE_ANY(val); + + if (size > arr->itemsize) + elog(ERROR, "safety check failed"); + + memcpy(VectorArrayGet(arr, offset), val, size); } /* Methods */