Skip to content

Commit 9f8f238

Browse files
baderouaichfacebook-github-bot
authored andcommitted
Fix potential buffer overflow (#3146)
Summary: Size of pointer `sub_x` used instead of size of its data. This is likely to lead to a buffer overflow if the user is not lucky enough to be in a x32 bit machine where `sizeof(float*) == sizeof(float)`. You probably intend to write `sizeof(*sub_x)` or `sizeof(float)` ? Pull Request resolved: #3146 Reviewed By: mlomeli1 Differential Revision: D51618892 Pulled By: algoriddle fbshipit-source-id: 82acd98009515e963c547d5c62946f93ef5561b5
1 parent 9107035 commit 9f8f238

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

faiss/MetaIndexes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void IndexSplitVectors::search(
9696
for (idx_t i = 0; i < n; i++)
9797
memcpy(sub_x.get() + i * sub_d,
9898
x + ofs + i * d,
99-
sub_d * sizeof(sub_x));
99+
sub_d * sizeof(float));
100100
sub_index->search(n, sub_x.get(), k, distances1, labels1);
101101
if (index->verbose)
102102
printf("end query shard %d\n", no);

0 commit comments

Comments
 (0)