Skip to content

Commit

Permalink
Merge pull request #484 from emollier/cve-2023-37365
Browse files Browse the repository at this point in the history
hnswalg.h: cap M to 100000
  • Loading branch information
yurymalkov authored Jul 20, 2023
2 parents 006d7b2 + 5aba6c6 commit f6d170c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
data_size_ = s->get_data_size();
fstdistfunc_ = s->get_dist_func();
dist_func_param_ = s->get_dist_func_param();
M_ = M;
if ( M <= 10000 ) {
M_ = M;
} else {
std::cerr << "warning: M parameter exceeds 10000 which may lead to adverse effects." << std::endl;
std::cerr << " Cap to 10000 will be applied for the rest of the processing." << std::endl;
M_ = 10000;
}
maxM_ = M_;
maxM0_ = M_ * 2;
ef_construction_ = std::max(ef_construction, M_);
Expand Down

0 comments on commit f6d170c

Please sign in to comment.