[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Mon Apr 11 12:57:40 UTC 2016


The branch master has been updated
       via  2d897ae4d8af83d7920ac4c52d0cab32739d671b (commit)
      from  cdbf577973a76a0627debb5105f46d6f4509c39e (commit)


- Log -----------------------------------------------------------------
commit 2d897ae4d8af83d7920ac4c52d0cab32739d671b
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Apr 8 20:15:15 2016 +0200

    BIO: respect opening in text mode
    
    When a file is opened with BIO_new_file(), make sure that the internal
    mode TEXT vs BINARY setting reflects what's given in the mode string.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/bio/bss_file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index 081c7f1..a37e89d 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -164,6 +164,10 @@ BIO *BIO_new_file(const char *filename, const char *mode)
 {
     BIO  *ret;
     FILE *file = file_fopen(filename, mode);
+    int fp_flags = BIO_CLOSE;
+
+    if (strchr(mode, 'b') == NULL)
+        fp_flags |= BIO_FP_TEXT;
 
     if (file == NULL) {
         SYSerr(SYS_F_FOPEN, get_last_sys_error());
@@ -181,7 +185,7 @@ BIO *BIO_new_file(const char *filename, const char *mode)
 
     BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
                                              * UPLINK */
-    BIO_set_fp(ret, file, BIO_CLOSE);
+    BIO_set_fp(ret, file, fp_flags);
     return (ret);
 }
 


More information about the openssl-commits mailing list