mirror of git://anongit.mindrot.org/openssh.git
Defer setting bufsiz in getdelim.
Do not write to bufsiz until we are sure the malloc has succeeded, in case any callers rely on it (which they shouldn't). ok djm@
This commit is contained in:
parent
3deb56f719
commit
872517ddbb
|
@ -53,9 +53,9 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
||||||
|
|
||||||
|
|
||||||
if (*buf == NULL || *bufsiz == 0) {
|
if (*buf == NULL || *bufsiz == 0) {
|
||||||
*bufsiz = BUFSIZ;
|
if ((*buf = malloc(BUFSIZ)) == NULL)
|
||||||
if ((*buf = malloc(*bufsiz)) == NULL)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
*bufsiz = BUFSIZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
||||||
|
|
Loading…
Reference in New Issue