mirror of
https://github.com/tmux/tmux.git
synced 2026-10-10 20:24:21 +00:00
fix(compat): guard buffer size multiplication in getline
This commit is contained in:
@@ -74,8 +74,14 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
|||||||
}
|
}
|
||||||
if (ptr + 2 >= eptr) {
|
if (ptr + 2 >= eptr) {
|
||||||
char *nbuf;
|
char *nbuf;
|
||||||
size_t nbufsiz = *bufsiz * 2;
|
size_t nbufsiz;
|
||||||
ssize_t d = ptr - *buf;
|
ssize_t d = ptr - *buf;
|
||||||
|
|
||||||
|
if (*bufsiz > SIZE_MAX / 2) {
|
||||||
|
errno = EOVERFLOW;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
nbufsiz = *bufsiz * 2;
|
||||||
if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
|
if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
*buf = nbuf;
|
*buf = nbuf;
|
||||||
|
|||||||
Reference in New Issue
Block a user