Hi, this is the first time I've sent a patch to OpenSSL so I hope I'm
using the right address and format.

In bio.h, there is a line:
#define BIO_set_nbio_accept(b,n)
BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)

The ternary argument...

    (n)?"a":NULL

...is troublesome for GCC because when the compiler mixes the const
char* string literal and the void* NULL, it decides that const void* is
the aggregate type. It then attempts to call BIO_ctrl with a const void*
parameter but BIO_ctrl takes a void*, so this results in a compile-time
error. The problem comes from the fact that, in C++, string literals are
const char* by default.

This could be solved by a compile option to GCC, but since bio.h is
included in user applications, and the #define macro gets expanded into
user code, every GCC user would need to define a potentially dangerous
compile option. Instead I suggest the following patch:

Index: bio.h
===================================================================
--- bio.h       (revision 32955)
+++ bio.h       (working copy)
@@ -413,7 +413,7 @@
 #define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char
*)name)
 #define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
 /* #define BIO_set_nbio(b,n)   BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
-#define BIO_set_nbio_accept(b,n)
BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)
+#define BIO_set_nbio_accept(b,n)
BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void*)"a":NULL)
 #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char
*)bio)
 
 #define BIO_BIND_NORMAL                        0


The addition of the void* cast helps GCC come up with a more acceptable
aggregate type. Note that there may be more issues like this in the
OpenSSL code, especially since there is widespread use of macros in
OpenSSL that will wind up being subject to the user's build environment.
However, in all of our application this was the only case we ran into.

Hope this helps,
David Fay

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to