Merge PR #1: avoid ever setting split_at to 0 (spqrz)
Safety fix in IRC message-splitting. The backtrack-to-space loop used 'while j > 0', which could set split_at to 0 if the first byte was a space — causing an empty prefix and an infinite re-split loop. Changed to 'while j > 1' so split_at is never 0. Co-Authored-By: spqrz <spqrz386@gmail.com> Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
commit
343aa12099
1 changed files with 1 additions and 1 deletions
|
|
@ -260,7 +260,7 @@ impl State {
|
|||
while i > 0 && !remaining.is_char_boundary(i) { i -= 1; }
|
||||
// To avoid splitting mid-word, see if there was a space recently
|
||||
let mut j = i;
|
||||
while j > 0 && j > i-10 && remaining.as_bytes()[j] != b' ' { j -= 1; }
|
||||
while j > 1 && j > i-10 && remaining.as_bytes()[j] != b' ' { j -= 1; }
|
||||
if remaining.as_bytes()[j] == b' ' { j }
|
||||
else if i == 0 { max_msg } else { i }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue