Skip to content

Commit f6d170c

Browse files
authored
Merge pull request #484 from emollier/cve-2023-37365
hnswalg.h: cap M to 100000
2 parents 006d7b2 + 5aba6c6 commit f6d170c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hnswlib/hnswalg.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
102102
data_size_ = s->get_data_size();
103103
fstdistfunc_ = s->get_dist_func();
104104
dist_func_param_ = s->get_dist_func_param();
105-
M_ = M;
105+
if ( M <= 10000 ) {
106+
M_ = M;
107+
} else {
108+
std::cerr << "warning: M parameter exceeds 10000 which may lead to adverse effects." << std::endl;
109+
std::cerr << " Cap to 10000 will be applied for the rest of the processing." << std::endl;
110+
M_ = 10000;
111+
}
106112
maxM_ = M_;
107113
maxM0_ = M_ * 2;
108114
ef_construction_ = std::max(ef_construction, M_);

0 commit comments

Comments
 (0)