Reject IVF binary quantizer when dimensions not divisible by 8

The binary quantizer uses D/8 for buffer sizes and memset, which
truncates for non-multiple-of-8 dimensions, causing OOB writes.
Rather than using ceiling division, enforce the constraint at
table creation time with a clear parse error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Garcia 2026-03-31 14:51:27 -07:00
parent 5e4c557f93
commit 4bee88384b
2 changed files with 20 additions and 0 deletions

View file

@ -3074,6 +3074,9 @@ int vec0_parse_vector_column(const char *source, int source_length,
if (rc != SQLITE_OK) {
return SQLITE_ERROR;
}
if (ivfConfig.quantizer == VEC0_IVF_QUANTIZER_BINARY && (dimensions % 8) != 0) {
return SQLITE_ERROR;
}
#else
return SQLITE_ERROR; // IVF not compiled in
#endif