Description:
Per the C spec, the system headers may legally define function-like macros
corresponding to any function they provide. In particular recent Red Hat
versions of <unistd.h> do this for read(), breaking vio code that assumes
it can use "read" as a random function pointer name. Attached is a minimal
workaround; it would likely be better to change the pointer's name.
How to repeat:
Try to build 4.1.10 on devel tip Fedora.
Suggested fix:
diff -Naur mysql-4.1.10.orig/include/violite.h mysql-4.1.10/include/violite.h
--- mysql-4.1.10.orig/include/violite.h 2005-02-12 15:37:32.000000000 -0500
+++ mysql-4.1.10/include/violite.h 2005-03-05 14:41:20.000000000 -0500
@@ -138,8 +138,9 @@
#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO)
#define vio_delete(vio) (vio)->viodelete(vio)
#define vio_errno(vio) (vio)->vioerrno(vio)
-#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
-#define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
+/* need parens in case read and write are defined as macros by system hdrs */
+#define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size)
+#define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size)
#define vio_blocking(vio, set_blocking_mode, old_mode)\
(vio)->vioblocking(vio, set_blocking_mode, old_mode)
#define vio_is_blocking(vio) (vio)->is_blocking(vio)
diff -Naur mysql-4.1.10.orig/vio/test-ssl.c mysql-4.1.10/vio/test-ssl.c
--- mysql-4.1.10.orig/vio/test-ssl.c 2005-02-12 15:37:34.000000000 -0500
+++ mysql-4.1.10/vio/test-ssl.c 2005-03-05 14:42:39.000000000 -0500
@@ -115,7 +115,7 @@
{
/* child, therefore, client */
char xbuf[100];
- int r = client_vio->read(client_vio,xbuf, sizeof(xbuf));
+ int r = vio_read(client_vio, xbuf, sizeof(xbuf));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
@@ -130,7 +130,7 @@
else
{
const char* s = "Huhuhuh";
- int r = server_vio->write(server_vio,(gptr)s, strlen(s));
+ int r = vio_write(server_vio,(gptr)s, strlen(s));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
diff -Naur mysql-4.1.10.orig/vio/test-sslclient.c mysql-4.1.10/vio/test-sslclient.c
--- mysql-4.1.10.orig/vio/test-sslclient.c 2005-02-12 15:37:32.000000000 -0500
+++ mysql-4.1.10/vio/test-sslclient.c 2005-03-05 14:43:21.000000000 -0500
@@ -83,7 +83,7 @@
/* Now we have TCP conncetion. Start SSL negotiation. */
read(client_vio->sd,xbuf, sizeof(xbuf));
sslconnect(ssl_connector,client_vio,60L);
- err = client_vio->read(client_vio,xbuf, sizeof(xbuf));
+ err = vio_read(client_vio,xbuf, sizeof(xbuf));
if (err<=0) {
my_free((gptr)ssl_connector,MYF(0));
fatal_error("client:SSL_read");