mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Fix two copy/paste bugs: forbid zero-length buffers to prevent a fatal error
when trying to paste them, found by me, and miscalculation of the start/end causing random fatal errors when copying in copy-mode, reported by sthen. ok sthen "put it in" deraadt
This commit is contained in:
parent
4c5c125173
commit
fe5edad1fc
@ -63,7 +63,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb != NULL)
|
if (pb != NULL && *pb->data != '\0')
|
||||||
buffer_write(w->active->out, pb->data, strlen(pb->data));
|
buffer_write(w->active->out, pb->data, strlen(pb->data));
|
||||||
|
|
||||||
/* Delete the buffer if -d. */
|
/* Delete the buffer if -d. */
|
||||||
|
3
paste.c
3
paste.c
@ -101,6 +101,9 @@ paste_add(struct paste_stack *ps, char *data, u_int limit)
|
|||||||
{
|
{
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
|
|
||||||
|
if (*data == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
while (ARRAY_LENGTH(ps) >= limit)
|
while (ARRAY_LENGTH(ps) >= limit)
|
||||||
ARRAY_TRUNC(ps, 1);
|
ARRAY_TRUNC(ps, 1);
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ window_copy_copy_selection(struct window_pane *wp, struct client *c)
|
|||||||
/* Find start and end. */
|
/* Find start and end. */
|
||||||
xx = data->cx + data->ox;
|
xx = data->cx + data->ox;
|
||||||
yy = screen_hsize(&wp->base) + data->cy - data->oy;
|
yy = screen_hsize(&wp->base) + data->cy - data->oy;
|
||||||
if (xx < data->selx || (yy == data->sely && xx < data->selx)) {
|
if (yy < data->sely || (yy == data->sely && xx < data->selx)) {
|
||||||
sx = xx; sy = yy;
|
sx = xx; sy = yy;
|
||||||
ex = data->selx; ey = data->sely;
|
ex = data->selx; ey = data->sely;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user