Changeset: 39ade36bf970 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/39ade36bf970
Modified Files:
        clients/examples/C/CMakeLists.txt
        clients/mapilib/connect.c
        clients/mapilib/connect_openssl.c
        clients/mapilib/msettings.h
        common/stream/openssl_stream.c
Branch: monetdburl
Log Message:

Windows fixex


diffs (92 lines):

diff --git a/clients/examples/C/CMakeLists.txt 
b/clients/examples/C/CMakeLists.txt
--- a/clients/examples/C/CMakeLists.txt
+++ b/clients/examples/C/CMakeLists.txt
@@ -88,6 +88,7 @@ add_executable(murltest
 
 target_link_libraries(murltest
   PRIVATE
+  monetdb_config_header
   mapi
 )
 
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -280,7 +280,6 @@ wrap_tls(Mapi mid, SOCKET sock)
 static MapiMsg
 connect_socket_unix(Mapi mid)
 {
-       (void)sockname;
        return mapi_setError(mid, "Unix domain sockets not supported", 
__func__, MERROR);
 }
 #endif
@@ -431,7 +430,7 @@ connect_socket_tcp(Mapi mid)
                static const char zeroes[8] = { 0 };
                ssize_t to_write = sizeof(zeroes);
                while (to_write > 0) {
-                       ssize_t n = send(s, zeroes, to_write, 0);
+                       ssize_t n = send(s, zeroes, (int)to_write, 0);
                        if (n < 0) {
                                closesocket(s);
                                return mapi_printError(mid, __func__, MERROR, 
"could not send leader block: %s", SOCKET_STRERROR());
diff --git a/clients/mapilib/connect_openssl.c 
b/clients/mapilib/connect_openssl.c
--- a/clients/mapilib/connect_openssl.c
+++ b/clients/mapilib/connect_openssl.c
@@ -143,7 +143,10 @@ wrap_tls(Mapi mid, SOCKET sock)
 
        // BIO 'sockbio' wraps the socket. OpenSSL will read and write
        // ciphertext from it.
-       BIO *sockbio = BIO_new_socket(sock, BIO_CLOSE);
+       //
+       // The OpenSSL developers apparently believe that it's safe to cast
+       // SOCKET to int here, see 
https://github.com/openssl/openssl/blob/openssl-3.1.3/include/internal/sockets.h#L54-L58
+       BIO *sockbio = BIO_new_socket((int)sock, BIO_CLOSE);
        if (sockbio == NULL) {
                closesocket(sock);
                BIO_free_all(bio);
diff --git a/clients/mapilib/msettings.h b/clients/mapilib/msettings.h
--- a/clients/mapilib/msettings.h
+++ b/clients/mapilib/msettings.h
@@ -1,3 +1,4 @@
+#include "monetdb_config.h"
 #include <stdbool.h>
 
 #define MP__BOOL_START (100)
diff --git a/common/stream/openssl_stream.c b/common/stream/openssl_stream.c
--- a/common/stream/openssl_stream.c
+++ b/common/stream/openssl_stream.c
@@ -71,7 +71,11 @@ ostream_read(stream *restrict s, void *r
        // iterate in order to read a complete number of items
        size_t pos = 0;
        do {
-               int nread = BIO_read(bio, start + pos, size - pos);
+               // pity we cannot use BIO_read_ex, BIO_read takes an int, not 
size_t
+               size_t to_read = size - pos;
+               if (to_read > INT_MAX)
+                       to_read = INT_MAX;
+               int nread = BIO_read(bio, start + pos, (int)to_read);
                if (nread < 0)
                        return ostream_error(s, MNSTR_READ_ERROR);
                if (nread == 0) {
@@ -82,7 +86,7 @@ ostream_read(stream *restrict s, void *r
 
                // adjust pos to the smallest multiple of elmsize.
                // example 1: size=4 pos=7 (-7)%4=1, newsize=8
-               size_t delta = (-pos) % size;
+               size_t delta = (0-pos) % size;
                if (size - pos > delta)
                        size = pos + delta;
        } while (pos < size);
@@ -99,7 +103,11 @@ ostream_write(stream *restrict s, const 
        size_t size = elmsize * cnt;
        size_t pos = 0;
        while (pos < size) {
-               int nwritten = BIO_write(bio, start + pos, size - pos);
+               // pity we cannot use BIO_write_ex, BIO_write takes an int, not 
size_t
+               size_t to_write = size - pos;
+               if (to_write > INT_MAX)
+                       to_write = INT_MAX;
+               int nwritten = BIO_write(bio, start + pos, (int)to_write);
                if (nwritten < 0)
                        return ostream_error(s, MNSTR_WRITE_ERROR);
                if (nwritten == 0 && !BIO_should_retry(bio))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to