LibLine: Reset state after invalid character in DSR response
While parsing DSR response, we might encounter invalid characters, for example, when we `cat` a binary file. Previously, we just pushed those characters in `m_incomplete_data` buffer, which worked fine until we didn't get a terminating character. We kept increasing coordinate value and crashed in following assertion.
This commit is contained in:
parent
7b3559f1c2
commit
1f0149e5a6
Notes:
sideshowbarker
2024-07-16 18:03:21 +09:00
Author: https://github.com/hanaa12G Commit: https://github.com/SerenityOS/serenity/commit/1f0149e5a6 Pull-request: https://github.com/SerenityOS/serenity/pull/21979 Issue: https://github.com/SerenityOS/serenity/issues/21978 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 6 additions and 0 deletions
|
@ -2128,14 +2128,17 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
|||
continue;
|
||||
}
|
||||
m_incomplete_data.append(c);
|
||||
state = Free;
|
||||
continue;
|
||||
case SawBracket:
|
||||
if (is_ascii_digit(c)) {
|
||||
state = InFirstCoordinate;
|
||||
coordinate_buffer.clear_with_capacity();
|
||||
coordinate_buffer.append(c);
|
||||
continue;
|
||||
}
|
||||
m_incomplete_data.append(c);
|
||||
state = Free;
|
||||
continue;
|
||||
case InFirstCoordinate:
|
||||
if (is_ascii_digit(c)) {
|
||||
|
@ -2152,6 +2155,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
|||
continue;
|
||||
}
|
||||
m_incomplete_data.append(c);
|
||||
state = Free;
|
||||
continue;
|
||||
case SawSemicolon:
|
||||
if (is_ascii_digit(c)) {
|
||||
|
@ -2160,6 +2164,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
|||
continue;
|
||||
}
|
||||
m_incomplete_data.append(c);
|
||||
state = Free;
|
||||
continue;
|
||||
case InSecondCoordinate:
|
||||
if (is_ascii_digit(c)) {
|
||||
|
@ -2176,6 +2181,7 @@ Result<Vector<size_t, 2>, Editor::Error> Editor::vt_dsr()
|
|||
continue;
|
||||
}
|
||||
m_incomplete_data.append(c);
|
||||
state = Free;
|
||||
continue;
|
||||
case SawR:
|
||||
m_incomplete_data.append(c);
|
||||
|
|
Loading…
Add table
Reference in a new issue