sshd/terminal/terminal.go: Clamp pos to protect from some fuzzing failures

This commit is contained in:
Andrey Petrov 2021-10-13 10:43:49 -04:00
parent db14517499
commit 0eebb64c1d

View File

@ -264,6 +264,10 @@ func (t *Terminal) moveCursorToPos(pos int) {
return
}
if pos > len(t.line) {
pos = len(t.line)
}
x := visualLength(t.prompt) + visualLength(t.line[:pos])
y := x / t.termWidth
x = x % t.termWidth