From 79b35228f1cc6fea47bab34611d79aab190f4f28 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 15 Nov 2016 10:10:32 +0100 Subject: [PATCH] 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) --- crypto/bio/bss_fd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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'; -- 2.25.1