On Tue, Jul 20, 1999 at 02:36:54PM +0200, Bodo Moeller wrote:

[...]
> Programs that access that structure directly cannot reasonably expect
> binary compatability across library versions.  Clean programs handle
> SSL_CTX's only as pointers.  A problem is just that, in case the
> application is written in C, you may not always notice that what you
> use is really a macro and not a function.

The harmful macros in <openssl/ssl.h> are:

#define SSL_CTX_sess_set_new_cb(ctx,cb) ((ctx)->new_session_cb=(cb))
#define SSL_CTX_sess_get_new_cb(ctx)    ((ctx)->new_session_cb)
#define SSL_CTX_sess_set_remove_cb(ctx,cb)      ((ctx)->remove_session_cb=(cb))
#define SSL_CTX_sess_get_remove_cb(ctx) ((ctx)->remove_session_cb)
#define SSL_CTX_sess_set_get_cb(ctx,cb) ((ctx)->get_session_cb=(cb))
#define SSL_CTX_sess_get_get_cb(ctx)    ((ctx)->get_session_cb)
#define SSL_CTX_set_info_callback(ctx,cb)       ((ctx)->info_callback=(cb))
#define SSL_CTX_get_info_callback(ctx)          ((ctx)->info_callback)
#define SSL_CTX_set_client_cert_cb(ctx,cb)      ((ctx)->client_cert_cb=(cb))
#define SSL_CTX_get_client_cert_cb(ctx)         ((ctx)->client_cert_cb)

<openssl/bio.h> also has some dangerous macros:

/* These shouldbe used by the application to tell why we should retry */
#define BIO_should_read(a)              ((a)->flags & BIO_FLAGS_READ)
#define BIO_should_write(a)             ((a)->flags & BIO_FLAGS_WRITE)
#define BIO_should_io_special(a)        ((a)->flags & BIO_FLAGS_IO_SPECIAL)
#define BIO_retry_type(a)               ((a)->flags & BIO_FLAGS_RWS)
#define BIO_should_retry(a)             ((a)->flags & BIO_FLAGS_SHOULD_RETRY)

#define BIO_set_callback(b,cb)          ((b)->callback=(cb))
#define BIO_set_callback_arg(b,arg)     ((b)->cb_arg=(char *)(arg))
#define BIO_get_callback_arg(b)         ((b)->cb_arg)
#define BIO_get_callback(b)             ((b)->callback)
#define BIO_method_name(b)              ((b)->method->name)
#define BIO_method_type(b)              ((b)->method->type)

#define BIO_number_read(b)      ((b)->num_read)
#define BIO_number_written(b)   ((b)->num_write)

In both header files there are also lots of macros that are based on
{SSL_CTX,SSL,BIO}_ctrl, which is the clean way to do things.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to