Following the license change, modify the boilerplates in test/
[openssl.git] / apps / bf_prefix.c
index 4d5e3a31c155590f5bba680f020f12514ab2a288..8cedca90ce1e319f1e9b090e108e8cb2d1fc3281 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -96,7 +96,7 @@ static int prefix_write(BIO *b, const char *out, size_t outl,
 
     *numwritten = 0;
 
-    while (*out != '\0') {
+    while (outl > 0) {
         size_t i;
         char c;
 
@@ -111,7 +111,7 @@ static int prefix_write(BIO *b, const char *out, size_t outl,
         }
 
         /* Now, go look for the next LF, or the end of the string */
-        for (i = 0; (c = out[i]) != '\n' && c != '\0'; i++)
+        for (i = 0, c = '\0'; i < outl && (c = out[i]) != '\n'; i++)
             continue;
         if (c == '\n')
             i++;
@@ -123,6 +123,7 @@ static int prefix_write(BIO *b, const char *out, size_t outl,
             if (!BIO_write_ex(BIO_next(b), out, i, &num))
                 return 0;
             out += num;
+            outl -= num;
             *numwritten += num;
             i -= num;
         }