Diagnose EOF on memory BIOs (or you just get mysterious errors with no error
authorBen Laurie <ben@openssl.org>
Mon, 28 Aug 2000 12:54:18 +0000 (12:54 +0000)
committerBen Laurie <ben@openssl.org>
Mon, 28 Aug 2000 12:54:18 +0000 (12:54 +0000)
message).

crypto/bio/bio.h
crypto/bio/bio_err.c
crypto/bio/bss_mem.c

index c727393..0e1a16c 100644 (file)
@@ -638,6 +638,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
 #define BIO_F_CONN_CTRL                                         127
 #define BIO_F_CONN_STATE                                115
 #define BIO_F_FILE_CTRL                                         116
+#define BIO_F_MEM_READ                                  128
 #define BIO_F_MEM_WRITE                                         117
 #define BIO_F_SSL_NEW                                   118
 #define BIO_F_WSASTARTUP                                119
@@ -648,6 +649,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
 #define BIO_R_BAD_HOSTNAME_LOOKUP                       102
 #define BIO_R_BROKEN_PIPE                               124
 #define BIO_R_CONNECT_ERROR                             103
+#define BIO_R_EOF_ON_MEMORY_BIO                                 127
 #define BIO_R_ERROR_SETTING_NBIO                        104
 #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET     105
 #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET       106
index f38e7b9..1d6a0e7 100644 (file)
@@ -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_MEM_READ,0), "MEM_READ"},
 {ERR_PACK(0,BIO_F_MEM_WRITE,0),        "MEM_WRITE"},
 {ERR_PACK(0,BIO_F_SSL_NEW,0),  "SSL_new"},
 {ERR_PACK(0,BIO_F_WSASTARTUP,0),       "WSASTARTUP"},
@@ -104,6 +105,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
 {BIO_R_BAD_HOSTNAME_LOOKUP               ,"bad hostname lookup"},
 {BIO_R_BROKEN_PIPE                       ,"broken pipe"},
 {BIO_R_CONNECT_ERROR                     ,"connect error"},
+{BIO_R_EOF_ON_MEMORY_BIO                 ,"eof on memory bio"},
 {BIO_R_ERROR_SETTING_NBIO                ,"error setting nbio"},
 {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET,"error setting nbio on accepted socket"},
 {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET,"error setting nbio on accept socket"},
index f8c144a..c4e5578 100644 (file)
@@ -166,6 +166,8 @@ static int mem_read(BIO *b, char *out, int outl)
                if (b->num != 0)
                        BIO_set_retry_read(b);
                ret= b->num;
+               if(ret < 0)
+                   BIOerr(BIO_F_MEM_READ,BIO_R_EOF_ON_MEMORY_BIO);
                }
        return(ret);
        }