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

This commit is contained in:
Andrey Petrov committed 2021-10-13 10:43:49 -04:00
1 parent db14517499
commit 0eebb64c1d
1 file changed
+4
+4
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