From: Richard Levitte Date: Tue, 13 Feb 2018 18:18:46 +0000 (+0100) Subject: Fix bug in BIO_f_linebuffer() X-Git-Tag: OpenSSL_1_1_0h~75 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a2019575614c0e9f81223348da360d058ff30883;p=oweals%2Fopenssl.git Fix bug in BIO_f_linebuffer() In BIO_f_linebuffer, this would cause an error: BIO_write(bio, "1\n", 1); I.e. there's a \n just after the part of the string that we currently ask to get written. Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/5353) --- diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c index 3f2ac2c3f1..58dd7ac1f5 100644 --- a/crypto/bio/bf_lbuf.c +++ b/crypto/bio/bf_lbuf.c @@ -116,9 +116,10 @@ static int linebuffer_write(BIO *b, const char *in, int inl) do { const char *p; + char c; - for (p = in; p < in + inl && *p != '\n'; p++) ; - if (*p == '\n') { + for (p = in, c = '\0'; p < in + inl && (c = *p) != '\n'; p++) ; + if (c == '\n') { p++; foundnl = 1; } else