Skip to content

Commit 8177528

Browse files
committed
Limit match length
Avoids quadratic runtime and potential DoS with adversarial inputs Ref oobabooga/text-generation-webui#6047
1 parent c68b3c8 commit 8177528

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mistralrs-core/src/sampler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ impl Sampler {
498498

499499
let mut match_length = 1;
500500

501-
loop {
501+
// Limit match length to avoid quadratic runtime and potential DoS with adversarial inputs.
502+
while match_length < 50 {
502503
if match_length > i {
503504
// Start of input
504505
break;

0 commit comments

Comments
 (0)