summaryrefslogtreecommitdiff
path: root/ssl/bio_ssl.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
committerRichard Levitte <levitte@openssl.org>2000-02-20 23:43:02 +0000
commitd3442bc780473f0cd4f378bc31130d4579da640b (patch)
treea9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /ssl/bio_ssl.c
parentdab6f09573742df94c4767663565aca3863f8173 (diff)
downloadopenssl-new-d3442bc780473f0cd4f378bc31130d4579da640b.tar.gz
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 'ssl/bio_ssl.c')
-rw-r--r--ssl/bio_ssl.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c
index aa296996e6..d73c41adcd 100644
--- a/ssl/bio_ssl.c
+++ b/ssl/bio_ssl.c
@@ -71,6 +71,7 @@ static int ssl_puts(BIO *h,char *str);
static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2);
static int ssl_new(BIO *h);
static int ssl_free(BIO *data);
+static long ssl_callback_ctrl(BIO *h,int cmd,void (*fp)());
typedef struct bio_ssl_st
{
SSL *ssl; /* The ssl handle :-) */
@@ -92,12 +93,7 @@ static BIO_METHOD methods_sslp=
ssl_ctrl,
ssl_new,
ssl_free,
- };
-
-union void_fn_to_char_u
- {
- char *char_p;
- void (*fn_p)();
+ ssl_callback_ctrl,
};
BIO_METHOD *BIO_f_ssl(void)
@@ -451,10 +447,12 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
break;
case BIO_CTRL_SET_CALLBACK:
{
- union void_fn_to_char_u tmp_cb;
-
- tmp_cb.char_p = ptr;
- SSL_set_info_callback(ssl,tmp_cb.fn_p);
+#if 0 /* FIXME: Should this be used? -- Richard Levitte */
+ BIOerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+ ret = -1;
+#else
+ ret=0;
+#endif
}
break;
case BIO_CTRL_GET_CALLBACK:
@@ -472,6 +470,28 @@ static long ssl_ctrl(BIO *b, int cmd, long num, char *ptr)
return(ret);
}
+static long ssl_callback_ctrl(BIO *b, int cmd, void (*fp)())
+ {
+ SSL *ssl;
+ BIO_SSL *bs;
+ long ret=1;
+
+ bs=(BIO_SSL *)b->ptr;
+ ssl=bs->ssl;
+ switch (cmd)
+ {
+ case BIO_CTRL_SET_CALLBACK:
+ {
+ SSL_set_info_callback(ssl,fp);
+ }
+ break;
+ default:
+ ret=BIO_callback_ctrl(ssl->rbio,cmd,fp);
+ break;
+ }
+ return(ret);
+ }
+
static int ssl_puts(BIO *bp, char *str)
{
int n,ret;