mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Fix osc52 null termination
This commit is contained in:
@@ -437,6 +437,8 @@ static bool
|
|||||||
accumulate_st_terminated_esc_code(PS *self, void(dispatch)(PS*, uint8_t*, size_t, bool)) {
|
accumulate_st_terminated_esc_code(PS *self, void(dispatch)(PS*, uint8_t*, size_t, bool)) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
if (find_st_terminator(self, &pos)) {
|
if (find_st_terminator(self, &pos)) {
|
||||||
|
// technically we should check MAX_ESCAPE_CODE_LENGTH here but lets be generous in what we accept since we
|
||||||
|
// have a full escape code
|
||||||
uint8_t *buf = self->buf + self->read.consumed;
|
uint8_t *buf = self->buf + self->read.consumed;
|
||||||
size_t sz = pos - self->read.consumed;
|
size_t sz = pos - self->read.consumed;
|
||||||
buf[sz] = 0; // ensure null termination, this is anyway an ST termination char
|
buf[sz] = 0; // ensure null termination, this is anyway an ST termination char
|
||||||
@@ -445,13 +447,14 @@ accumulate_st_terminated_esc_code(PS *self, void(dispatch)(PS*, uint8_t*, size_t
|
|||||||
}
|
}
|
||||||
if (UNLIKELY((pos=self->read.pos - self->read.consumed) > MAX_ESCAPE_CODE_LENGTH)) {
|
if (UNLIKELY((pos=self->read.pos - self->read.consumed) > MAX_ESCAPE_CODE_LENGTH)) {
|
||||||
if (self->vte_state == VTE_OSC && is_osc_52(self)) {
|
if (self->vte_state == VTE_OSC && is_osc_52(self)) {
|
||||||
uint8_t *buf = self->buf + self->read.consumed;
|
|
||||||
// null terminate
|
// null terminate
|
||||||
self->read.pos--;
|
self->read.pos--;
|
||||||
uint8_t before = buf[pos];
|
uint8_t before = self->buf[self->read.pos];
|
||||||
buf[self->read.pos] = 0; // ensure null termination, this is anyway an ST termination char
|
self->buf[self->read.pos] = 0;
|
||||||
dispatch(self, buf, self->read.pos - self->read.consumed, true);
|
// send partial OSC 52
|
||||||
buf[self->read.pos] = before;
|
dispatch(self, self->buf + self->read.consumed, self->read.pos - self->read.consumed, true);
|
||||||
|
// continue OSC 52
|
||||||
|
self->buf[self->read.pos] = before;
|
||||||
continue_osc_52(self);
|
continue_osc_52(self);
|
||||||
return accumulate_st_terminated_esc_code(self, dispatch);
|
return accumulate_st_terminated_esc_code(self, dispatch);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user