[openssh-commits] [openssh] 01/01: Defer setting bufsiz in getdelim.

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Jul 6 13:34:13 AEST 2018


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 872517ddbb72deaff31d4760f28f2b0a1c16358f
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Fri Jul 6 13:32:02 2018 +1000

    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@
---
 openbsd-compat/bsd-getline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/openbsd-compat/bsd-getline.c b/openbsd-compat/bsd-getline.c
index 681062e8..d676f4ce 100644
--- a/openbsd-compat/bsd-getline.c
+++ b/openbsd-compat/bsd-getline.c
@@ -53,9 +53,9 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
 
 
 	if (*buf == NULL || *bufsiz == 0) {
-		*bufsiz = BUFSIZ;
-		if ((*buf = malloc(*bufsiz)) == NULL)
+		if ((*buf = malloc(BUFSIZ)) == NULL)
 			return -1;
+		*bufsiz = BUFSIZ;
 	}
 
 	for (ptr = *buf, eptr = *buf + *bufsiz;;) {

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list