From: Tomas Mraz Date: Tue, 15 Nov 2016 09:10:32 +0000 (+0100) Subject: Do not eat trailing '\n' in BIO_gets for fd BIO. X-Git-Tag: OpenSSL_1_1_1-pre1~1505 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=79b35228f1cc6fea47bab34611d79aab190f4f28;p=oweals%2Fopenssl.git Do not eat trailing '\n' in BIO_gets for fd BIO. Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/3442) --- diff --git a/crypto/bio/bss_fd.c b/crypto/bio/bss_fd.c index 49976e7f80..2a9a0422a2 100644 --- a/crypto/bio/bss_fd.c +++ b/crypto/bio/bss_fd.c @@ -207,8 +207,10 @@ static int fd_gets(BIO *bp, char *buf, int size) char *ptr = buf; char *end = buf + size - 1; - while ((ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n')) - ptr++; + while (ptr < end && fd_read(bp, ptr, 1) > 0) { + if (*ptr++ == '\n') + break; + } ptr[0] = '\0';