From d15711efc6c82d5483dcf73ac7fa3ec5deb2c24a Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Tue, 11 Jun 2002 12:41:37 +0000 Subject: Handle read errors. --- crypto/bio/bio.h | 1 + crypto/bio/bio_err.c | 1 + crypto/bio/bss_file.c | 6 ++++++ crypto/err/err.c | 1 + crypto/err/err.h | 1 + 5 files changed, 10 insertions(+) (limited to 'crypto') diff --git a/crypto/bio/bio.h b/crypto/bio/bio.h index b122c7069d..8aefeac3d7 100644 --- a/crypto/bio/bio.h +++ b/crypto/bio/bio.h @@ -647,6 +647,7 @@ void ERR_load_BIO_strings(void); #define BIO_F_CONN_CTRL 127 #define BIO_F_CONN_STATE 115 #define BIO_F_FILE_CTRL 116 +#define BIO_F_FILE_READ 130 #define BIO_F_LINEBUFFER_CTRL 129 #define BIO_F_MEM_READ 128 #define BIO_F_MEM_WRITE 117 diff --git a/crypto/bio/bio_err.c b/crypto/bio/bio_err.c index 99ca3cd0da..68a119d895 100644 --- a/crypto/bio/bio_err.c +++ b/crypto/bio/bio_err.c @@ -91,6 +91,7 @@ static ERR_STRING_DATA BIO_str_functs[]= {ERR_PACK(0,BIO_F_CONN_CTRL,0), "CONN_CTRL"}, {ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, {ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, +{ERR_PACK(0,BIO_F_FILE_READ,0), "FILE_READ"}, {ERR_PACK(0,BIO_F_LINEBUFFER_CTRL,0), "LINEBUFFER_CTRL"}, {ERR_PACK(0,BIO_F_MEM_READ,0), "MEM_READ"}, {ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index 8b3ff278d9..826b361fa2 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -162,6 +162,12 @@ static int MS_CALLBACK file_read(BIO *b, char *out, int outl) if (b->init && (out != NULL)) { ret=fread(out,1,(int)outl,(FILE *)b->ptr); + if(ret == 0 && ferror((FILE *)b->ptr)) + { + SYSerr(SYS_F_FREAD,get_last_sys_error()); + BIOerr(BIO_F_FILE_READ,ERR_R_SYS_LIB); + ret=-1; + } } return(ret); } diff --git a/crypto/err/err.c b/crypto/err/err.c index 04773d65a6..5abe44e6d5 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -166,6 +166,7 @@ static ERR_STRING_DATA ERR_str_functs[]= {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, #endif {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, + {ERR_PACK(0,SYS_F_FREAD,0), "fread"}, {0,NULL}, }; diff --git a/crypto/err/err.h b/crypto/err/err.h index 76dc9e45d4..8728ff7c02 100644 --- a/crypto/err/err.h +++ b/crypto/err/err.h @@ -184,6 +184,7 @@ typedef struct err_state_st #define SYS_F_ACCEPT 8 #define SYS_F_WSASTARTUP 9 /* Winsock stuff */ #define SYS_F_OPENDIR 10 +#define SYS_F_FREAD 11 /* reasons */ -- cgit v1.2.3