diff options
author | Rich Salz <rsalz@openssl.org> | 2017-04-28 14:14:59 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-04-28 14:14:59 -0400 |
commit | 595b2a42375427a254ad5a8c85870efea839a9b9 (patch) | |
tree | 288959e5c956b0306e34ca185b092a6b3f940950 /crypto/bio | |
parent | 5cc977619181d5dd68fba7ec6e185550f824a6db (diff) |
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@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3266)
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bss_file.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index adf935f350..ae9867e037 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -190,6 +190,7 @@ static long 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: @@ -317,10 +318,14 @@ static long 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; |