Do not eat trailing '\n' in BIO_gets for fd BIO.
authorTomas Mraz <tmraz@fedoraproject.org>
Tue, 15 Nov 2016 09:10:32 +0000 (10:10 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 15 May 2017 13:13:36 +0000 (15:13 +0200)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3442)

crypto/bio/bss_fd.c

index 49976e7f8004c9cf581a90a7f19552a490a0a80a..2a9a0422a235a002991d30e12dc0e85083e18305 100644 (file)
@@ -207,8 +207,10 @@ static int fd_gets(BIO *bp, char *buf, int size)
     char *ptr = buf;
     char *end = buf + size - 1;
 
     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';
 
 
     ptr[0] = '\0';