pgvector.git / summary / log / commit / refs

commit    dcf206128aa2501f4b3cde012c4ed276c3f69b2d
Author:   Nathan Bossart <bossartn@amazon.com>
Commit:   GitHub <noreply@github.com>
Date:     Sat May 13 00:08:51 2023 +0000

    Check bounds unconditionally in array_to_vector(). (#127)
    
    Presently, array_to_vector()'s call to CheckDim() is skipped when typmod != -1, which allows for bypassing VECTOR_MAX_DIM.  To fix, call Check[Expected]Dim() unconditionally.  CheckExpectedDim() takes no action when typmod == -1, so there's no need to guard it with an 'if' statement.


src/vector.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vector.c b/src/vector.c index 7c128e56..ebb071a6 100644 --- a/src/vector.c +++ b/src/vector.c @@ -396,10 +396,8 @@ array_to_vector(PG_FUNCTION_ARGS) get_typlenbyvalalign(ARR_ELEMTYPE(array), &typlen, &typbyval, &typalign); deconstruct_array(array, ARR_ELEMTYPE(array), typlen, typbyval, typalign, &elemsp, &nullsp, &nelemsp); - if (typmod == -1) - CheckDim(nelemsp); - else - CheckExpectedDim(typmod, nelemsp); + CheckDim(nelemsp); + CheckExpectedDim(typmod, nelemsp); result = InitVector(nelemsp); for (i = 0; i < nelemsp; i++) [parent: 3244d40e8a53]