mirror of
https://github.com/tmux/tmux.git
synced 2024-11-18 02:18:53 +00:00
Sync OpenBSD patchset 529:
Add an explicit zero-length check for UTF-8 input data, prompted by a report from parfait via deraadt. While here, add a statement to set the width when filling with _s if not enough space (width should never be high enough at the moment anyway), and wrap some long lines.
This commit is contained in:
parent
e8424d333e
commit
2ec5aca064
@ -1,4 +1,4 @@
|
|||||||
/* $Id: screen-write.c,v 1.83 2009-10-23 17:16:24 tcunha Exp $ */
|
/* $Id: screen-write.c,v 1.84 2009-11-13 16:54:04 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1039,6 +1039,8 @@ screen_write_cell(struct screen_write_ctx *ctx,
|
|||||||
/* Construct UTF-8 and write it. */
|
/* Construct UTF-8 and write it. */
|
||||||
gu.width = utf8data->width;
|
gu.width = utf8data->width;
|
||||||
memset(gu.data, 0xff, sizeof gu.data);
|
memset(gu.data, 0xff, sizeof gu.data);
|
||||||
|
if (utf8data->size == 0)
|
||||||
|
fatalx("UTF-8 data empty");
|
||||||
if (utf8data->size > sizeof gu.data)
|
if (utf8data->size > sizeof gu.data)
|
||||||
fatalx("UTF-8 data overflow");
|
fatalx("UTF-8 data overflow");
|
||||||
memcpy(gu.data, utf8data->data, utf8data->size);
|
memcpy(gu.data, utf8data->data, utf8data->size);
|
||||||
@ -1084,6 +1086,10 @@ screen_write_combine(
|
|||||||
if (s->cx == 0)
|
if (s->cx == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
/* Empty utf8data is out. */
|
||||||
|
if (utf8data->size == 0)
|
||||||
|
fatalx("UTF-8 data empty");
|
||||||
|
|
||||||
/* Retrieve the previous cell and convert to UTF-8 if not already. */
|
/* Retrieve the previous cell and convert to UTF-8 if not already. */
|
||||||
gc = grid_view_get_cell(gd, s->cx - 1, s->cy);
|
gc = grid_view_get_cell(gd, s->cx - 1, s->cy);
|
||||||
if (!(gc->flags & GRID_FLAG_UTF8)) {
|
if (!(gc->flags & GRID_FLAG_UTF8)) {
|
||||||
@ -1108,6 +1114,7 @@ screen_write_combine(
|
|||||||
gu->data[i] = '_';
|
gu->data[i] = '_';
|
||||||
if (i != UTF8_SIZE)
|
if (i != UTF8_SIZE)
|
||||||
gu->data[i] = 0xff;
|
gu->data[i] = 0xff;
|
||||||
|
gu->width = i;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1166,14 +1173,16 @@ screen_write_overwrite(struct screen_write_ctx *ctx)
|
|||||||
gu = grid_view_peek_utf8(gd, s->cx, s->cy);
|
gu = grid_view_peek_utf8(gd, s->cx, s->cy);
|
||||||
if (gu->width > 1) {
|
if (gu->width > 1) {
|
||||||
/*
|
/*
|
||||||
* An UTF-8 wide cell; overwrite following padding cells only.
|
* An UTF-8 wide cell; overwrite following padding
|
||||||
|
* cells only.
|
||||||
*/
|
*/
|
||||||
xx = s->cx;
|
xx = s->cx;
|
||||||
while (++xx < screen_size_x(s)) {
|
while (++xx < screen_size_x(s)) {
|
||||||
gc = grid_view_peek_cell(gd, xx, s->cy);
|
gc = grid_view_peek_cell(gd, xx, s->cy);
|
||||||
if (!(gc->flags & GRID_FLAG_PADDING))
|
if (!(gc->flags & GRID_FLAG_PADDING))
|
||||||
break;
|
break;
|
||||||
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
|
grid_view_set_cell(
|
||||||
|
gd, xx, s->cy, &grid_default_cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user