Fixing one of my own bugs, there since SSLeay days I belive :-)

If a short PEM encoded sequence is passed to the BIO, and the file
has 2 \n following, it will fail.
openssl asn1parse -in f2.bad
where f2.bad = <<EOF
-----BEGIN PARAMETERS-----
MA0GByqGSM49AQECAgD/
-----END PARAMETERS-----

EOF

The patch is

diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index 72a2a67..ac6d441 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -264,7 +264,7 @@ static int b64_read(BIO *b, char *out, int outl)
                                }
 
                        /* we fell off the end without starting */
-                       if (j == i)
+                       if ((j == i) && (num == 0))
                                {
                                /* Is this is one long chunk?, if so, keep on
                                 * reading until a new line. */

Attached is a tar of working/failing cases


Attachment: bio_b64-bug.tar.gz
Description: application/compressed-tar

Reply via email to