fix(lib): cap a search reply at 150 files

A broad query against a big share was answered with every match, so one
search could hand the whole index to a stranger, and every such search
did it again. A reply now carries at most MAX_SEARCH_REPLY_FILES (150,
Nicotine+'s default), which is more sources than any searcher scrolls
through.
This commit is contained in:
Michel de Graaf
2026-09-07 14:44:16 +02:00
parent ef563fbb7e
commit b9d3d7fcd5
3 changed files with 99 additions and 38 deletions
+1
View File
@@ -146,6 +146,7 @@ fn build_search_response(
}
let entries: Vec<FileEntry> = matches
.iter()
.take(crate::types::MAX_SEARCH_REPLY_FILES)
.map(|f| FileEntry {
name: &f.virtual_path,
size: f.size,