mirror of
https://github.com/tmux/tmux.git
synced 2026-02-13 09:19:17 +00:00
Do not write before buffer when parsing empty clipboard or palette
replies, or try to allocate zero bytes with an empty clipboard sequence. Reported by DongHan Kim.
This commit is contained in:
16
tty-keys.c
16
tty-keys.c
@@ -1377,6 +1377,10 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
|
|||||||
|
|
||||||
/* Convert from base64. */
|
/* Convert from base64. */
|
||||||
needed = (end / 4) * 3;
|
needed = (end / 4) * 3;
|
||||||
|
if (needed == 0) {
|
||||||
|
free(copy);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
out = xmalloc(needed);
|
out = xmalloc(needed);
|
||||||
if ((outlen = b64_pton(copy, out, len)) == -1) {
|
if ((outlen = b64_pton(copy, out, len)) == -1) {
|
||||||
free(out);
|
free(out);
|
||||||
@@ -1612,8 +1616,10 @@ tty_keys_extended_device_attributes(struct tty *tty, const char *buf,
|
|||||||
}
|
}
|
||||||
if (i == (sizeof tmp) - 1)
|
if (i == (sizeof tmp) - 1)
|
||||||
return (-1);
|
return (-1);
|
||||||
tmp[i - 1] = '\0';
|
|
||||||
*size = 5 + i;
|
*size = 5 + i;
|
||||||
|
if (i == 0)
|
||||||
|
return (0);
|
||||||
|
tmp[i - 1] = '\0';
|
||||||
|
|
||||||
/* Add terminal features. */
|
/* Add terminal features. */
|
||||||
if (strncmp(tmp, "iTerm2 ", 7) == 0)
|
if (strncmp(tmp, "iTerm2 ", 7) == 0)
|
||||||
@@ -1686,11 +1692,13 @@ tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size,
|
|||||||
}
|
}
|
||||||
if (i == (sizeof tmp) - 1)
|
if (i == (sizeof tmp) - 1)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
*size = 6 + i;
|
||||||
|
if (i == 0)
|
||||||
|
return (0);
|
||||||
if (tmp[i - 1] == '\033')
|
if (tmp[i - 1] == '\033')
|
||||||
tmp[i - 1] = '\0';
|
tmp[i - 1] = '\0';
|
||||||
else
|
else
|
||||||
tmp[i] = '\0';
|
tmp[i] = '\0';
|
||||||
*size = 6 + i;
|
|
||||||
|
|
||||||
/* Work out the colour. */
|
/* Work out the colour. */
|
||||||
n = colour_parseX11(tmp);
|
n = colour_parseX11(tmp);
|
||||||
@@ -1755,11 +1763,13 @@ tty_keys_palette(struct tty *tty, const char *buf, size_t len, size_t *size)
|
|||||||
}
|
}
|
||||||
if (i == (sizeof tmp) - 1)
|
if (i == (sizeof tmp) - 1)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
*size = 5 + i;
|
||||||
|
if (i == 0)
|
||||||
|
return (0);
|
||||||
if (tmp[i - 1] == '\033')
|
if (tmp[i - 1] == '\033')
|
||||||
tmp[i - 1] = '\0';
|
tmp[i - 1] = '\0';
|
||||||
else
|
else
|
||||||
tmp[i] = '\0';
|
tmp[i] = '\0';
|
||||||
*size = 5 + i;
|
|
||||||
|
|
||||||
/* Parse index. */
|
/* Parse index. */
|
||||||
idx = strtol(tmp, &endptr, 10);
|
idx = strtol(tmp, &endptr, 10);
|
||||||
|
|||||||
Reference in New Issue
Block a user