]> granicus.if.org Git - openssl/commitdiff
Fix bug in BIO_f_linebuffer()
authorRichard Levitte <levitte@openssl.org>
Tue, 13 Feb 2018 18:18:46 +0000 (19:18 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 13 Feb 2018 18:24:22 +0000 (19:24 +0100)
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 <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5353)

crypto/bio/bf_lbuf.c

index 3f2ac2c3f1071a623874ab1f11c81083a3128793..58dd7ac1f56e3586db2907c67d7e997fee3cf6e3 100644 (file)
@@ -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