[openssl-commits] [openssl] OpenSSL_1_0_2-stable update

Rich Salz rsalz at openssl.org
Sun Apr 30 14:11:30 UTC 2017


The branch OpenSSL_1_0_2-stable has been updated
       via  13f70ae2a9734b8eedea337aa947a75d27ed8320 (commit)
      from  de46e8246bf30f9d8a6b8a66b37f8bf63115aeb6 (commit)


- Log -----------------------------------------------------------------
commit 13f70ae2a9734b8eedea337aa947a75d27ed8320
Author: Rich Salz <rsalz at openssl.org>
Date:   Sun Apr 30 10:11:07 2017 -0400

    Check fflush on BIO_ctrl call
    
    Bug found and fix suggested by Julian Rüth.
    Push error if fflush fails
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3266)
    (cherry picked from commit 595b2a42375427a254ad5a8c85870efea839a9b9)
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3348)

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

Summary of changes:
 crypto/bio/bss_file.c | 13 +++++++++----
 crypto/err/err.c      |  1 +
 crypto/err/err.h      |  1 +
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index abdcf4e..0cf67e5 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -287,6 +287,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
     FILE *fp = (FILE *)b->ptr;
     FILE **fpp;
     char p[4];
+    int st;
 
     switch (cmd) {
     case BIO_C_FILE_SEEK:
@@ -427,10 +428,14 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
         b->shutdown = (int)num;
         break;
     case BIO_CTRL_FLUSH:
-        if (b->flags & BIO_FLAGS_UPLINK)
-            UP_fflush(b->ptr);
-        else
-            fflush((FILE *)b->ptr);
+        st = b->flags & BIO_FLAGS_UPLINK
+                ? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);
+        if (st == EOF) {
+            SYSerr(SYS_F_FFLUSH, get_last_sys_error());
+            ERR_add_error_data(1, "fflush()");
+            BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
+            ret = 0;
+        }
         break;
     case BIO_CTRL_DUP:
         ret = 1;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 52dc9a5..0b1fcfc 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -172,6 +172,7 @@ static ERR_STRING_DATA ERR_str_functs[] = {
 # endif
     {ERR_PACK(0, SYS_F_OPENDIR, 0), "opendir"},
     {ERR_PACK(0, SYS_F_FREAD, 0), "fread"},
+    {ERR_PACK(0, SYS_F_FFLUSH, 0), "fflush"},
     {0, NULL},
 };
 
diff --git a/crypto/err/err.h b/crypto/err/err.h
index 585aa8b..f423656 100644
--- a/crypto/err/err.h
+++ b/crypto/err/err.h
@@ -258,6 +258,7 @@ typedef struct err_state_st {
 # define SYS_F_WSASTARTUP        9/* Winsock stuff */
 # define SYS_F_OPENDIR           10
 # define SYS_F_FREAD             11
+# define SYS_F_FFLUSH            18
 
 /* reasons */
 # define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */


More information about the openssl-commits mailing list