summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bf_buff.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-02-21 00:43:02 +0100
committerRichard Levitte <levitte@openssl.org>2000-02-21 00:43:02 +0100
commitd3442bc780473f0cd4f378bc31130d4579da640b (patch)
treea9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /crypto/bio/bf_buff.c
parentWorkaround for irrelevant problem. (diff)
downloadopenssl-d3442bc780473f0cd4f378bc31130d4579da640b.tar.xz
openssl-d3442bc780473f0cd4f378bc31130d4579da640b.zip
Move the registration of callback functions to special functions
designed for that. This removes the potential error to mix data and function pointers. Please note that I'm a little unsure how incorrect calls to the old ctrl functions should be handled, in som cases. I currently return 0 and that's it, but it may be more correct to generate a genuine error in those cases.
Diffstat (limited to 'crypto/bio/bf_buff.c')
-rw-r--r--crypto/bio/bf_buff.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index acd8148138..ff0c9070ae 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -69,6 +69,7 @@ static int buffer_gets(BIO *h,char *str,int size);
static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int buffer_new(BIO *h);
static int buffer_free(BIO *data);
+static long buffer_callback_ctrl(BIO *h,int cmd, void (*fp)());
#define DEFAULT_BUFFER_SIZE 1024
static BIO_METHOD methods_buffer=
@@ -82,6 +83,7 @@ static BIO_METHOD methods_buffer=
buffer_ctrl,
buffer_new,
buffer_free,
+ buffer_callback_ctrl,
};
BIO_METHOD *BIO_f_buffer(void)
@@ -284,6 +286,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
ctx->ibuf_len=0;
ctx->obuf_off=0;
ctx->obuf_len=0;
+ if (b->next_bio == NULL) return(0);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_CTRL_INFO:
@@ -300,12 +303,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
case BIO_CTRL_WPENDING:
ret=(long)ctx->obuf_len;
if (ret == 0)
+ {
+ if (b->next_bio == NULL) return(0);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
+ }
break;
case BIO_CTRL_PENDING:
ret=(long)ctx->ibuf_len;
if (ret == 0)
+ {
+ if (b->next_bio == NULL) return(0);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
+ }
break;
case BIO_C_SET_BUFF_READ_DATA:
if (num > ctx->ibuf_size)
@@ -374,12 +383,14 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr)
}
break;
case BIO_C_DO_STATE_MACHINE:
+ if (b->next_bio == NULL) return(0);
BIO_clear_retry_flags(b);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
BIO_copy_next_retry(b);
break;
case BIO_CTRL_FLUSH:
+ if (b->next_bio == NULL) return(0);
if (ctx->obuf_len <= 0)
{
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -418,6 +429,7 @@ fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_
ret=0;
break;
default:
+ if (b->next_bio == NULL) return(0);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
}
@@ -427,6 +439,20 @@ malloc_error:
return(0);
}
+static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ long ret=1;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ default:
+ ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
static int buffer_gets(BIO *b, char *buf, int size)
{
BIO_F_BUFFER_CTX *ctx;