[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Mon Oct 5 07:26:53 UTC 2015


The branch master has been updated
       via  5f0580ccf126a4834a406423e15da5b8a8bdf993 (commit)
       via  21ff9ac815f363a4fc9c8dc80ca09f0a5b2f02ef (commit)
       via  45f1351821a44f4ba7b5c6485277ba7729b6ec4a (commit)
       via  b13fdc4860b5e1bf615b113950788a138e68ae7f (commit)
      from  f93ad22f6adb00e722c130e792799467f3927b56 (commit)


- Log -----------------------------------------------------------------
commit 5f0580ccf126a4834a406423e15da5b8a8bdf993
Author: Andy Polyakov <appro at openssl.org>
Date:   Wed Sep 30 10:36:21 2015 +0200

    Harmonize pointer printing and size_t-fy casts.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

commit 21ff9ac815f363a4fc9c8dc80ca09f0a5b2f02ef
Author: Andy Polyakov <appro at openssl.org>
Date:   Wed Sep 30 10:28:14 2015 +0200

    bio/bss_log.c: harmonize format string to silence -Wformat.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

commit 45f1351821a44f4ba7b5c6485277ba7729b6ec4a
Author: Andy Polyakov <appro at openssl.org>
Date:   Wed Sep 30 10:27:19 2015 +0200

    Address Windows warnings in apps/.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

commit b13fdc4860b5e1bf615b113950788a138e68ae7f
Author: Andy Polyakov <appro at openssl.org>
Date:   Wed Sep 30 10:15:03 2015 +0200

    Explicitly cast INVALID_SOCKET to (int) to address warnings on Windows.
    
    Even though SOCKET is effectively declared as (void *) on Windows, it's
    not actually a pointer, but an index within per-process table of
    kernel objects. The table size is actually limited and its upper limit
    is far below upper limit for signed 32-bit integer. This is what makes
    cast in question possible.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    Reviewed-by: Tim Hudson <tjh at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/opt.c            |  3 +--
 apps/s_socket.c       | 12 ++++++------
 apps/s_time.c         | 23 -----------------------
 crypto/bio/b_print.c  |  2 +-
 crypto/bio/b_sock.c   | 20 ++++++++++----------
 crypto/bio/bss_acpt.c | 12 ++++++------
 crypto/bio/bss_conn.c |  8 ++++----
 crypto/bio/bss_log.c  |  2 +-
 crypto/mem_dbg.c      |  8 ++++----
 crypto/thr_id.c       |  2 +-
 e_os.h                |  4 +++-
 11 files changed, 37 insertions(+), 59 deletions(-)

diff --git a/apps/opt.c b/apps/opt.c
index c7dcc43..90a9d84 100644
--- a/apps/opt.c
+++ b/apps/opt.c
@@ -80,8 +80,7 @@ static char prog[40];
 #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_NETWARE)
 char *opt_progname(const char *argv0)
 {
-    int i;
-    int n;
+    size_t i, n;
     const char *p;
     char *q;
 
diff --git a/apps/s_socket.c b/apps/s_socket.c
index c1faffc..9d1f04a 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -266,7 +266,7 @@ static int init_client_ip(int *sock, const unsigned char ip[4], int port,
     else                        /* ( type == SOCK_DGRAM) */
         s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
-    if (s == INVALID_SOCKET) {
+    if (s == (int)INVALID_SOCKET) {
         perror("socket");
         return (0);
     }
@@ -303,7 +303,7 @@ int init_client_unix(int *sock, const char *server)
         return (0);
 
     s = socket(AF_UNIX, SOCK_STREAM, 0);
-    if (s == INVALID_SOCKET) {
+    if (s == (int)INVALID_SOCKET) {
         perror("socket");
         return (0);
     }
@@ -428,7 +428,7 @@ static int init_server_long(int *sock, int port, char *ip, int type)
     else                        /* type == SOCK_DGRAM */
         s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
-    if (s == INVALID_SOCKET)
+    if (s == (int)INVALID_SOCKET)
         goto err;
 # if defined SOL_SOCKET && defined SO_REUSEADDR
     {
@@ -472,7 +472,7 @@ static int init_server_unix(int *sock, const char *path)
         return (0);
 
     s = socket(AF_UNIX, SOCK_STREAM, 0);
-    if (s == INVALID_SOCKET)
+    if (s == (int)INVALID_SOCKET)
         goto err;
 
     memset(&server, 0, sizeof(server));
@@ -527,7 +527,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
      * can either go for (int *) or (void *).
      */
     ret = accept(acc_sock, (struct sockaddr *)&from, (void *)&len);
-    if (ret == INVALID_SOCKET) {
+    if (ret == (int)INVALID_SOCKET) {
 # if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK))
         int i;
         i = WSAGetLastError();
@@ -589,7 +589,7 @@ static int do_accept_unix(int acc_sock, int *sock)
 
  redoit:
     ret = accept(acc_sock, NULL, NULL);
-    if (ret == INVALID_SOCKET) {
+    if (ret == (int)INVALID_SOCKET) {
         if (errno == EINTR) {
             /*
              * check_timeout();
diff --git a/apps/s_time.c b/apps/s_time.c
index 91d28c2..6514fb2 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -73,10 +73,6 @@
 #include <openssl/pem.h>
 #include "s_apps.h"
 #include <openssl/err.h>
-#ifdef WIN32_STUFF
-# include "winmain.h"
-# include "wintext.h"
-#endif
 #if !defined(OPENSSL_SYS_MSDOS)
 # include OPENSSL_UNISTD
 #endif
@@ -166,9 +162,6 @@ int s_time_main(int argc, char **argv)
         0, ver;
     long bytes_read = 0, finishtime = 0;
     OPTION_CHOICE o;
-#ifdef OPENSSL_SYS_WIN32
-    int exitNow = 0;            /* Set when it's time to exit main */
-#endif
 
     meth = TLS_client_method();
     verify_depth = 0;
@@ -281,14 +274,6 @@ int s_time_main(int argc, char **argv)
     for (;;) {
         if (finishtime < (long)time(NULL))
             break;
-#ifdef WIN32_STUFF
-
-        if (flushWinMsgs(0) == -1)
-            goto end;
-
-        if (waitingToDie || exitNow) /* we're dead */
-            goto end;
-#endif
 
         if ((scon = doConnection(NULL, host, ctx)) == NULL)
             goto end;
@@ -378,14 +363,6 @@ int s_time_main(int argc, char **argv)
         if (finishtime < (long)time(NULL))
             break;
 
-#ifdef WIN32_STUFF
-        if (flushWinMsgs(0) == -1)
-            goto end;
-
-        if (waitingToDie || exitNow) /* we're dead */
-            goto end;
-#endif
-
         if ((doConnection(scon, host, ctx)) == NULL)
             goto end;
 
diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c
index 06cadc8..f49ebee 100644
--- a/crypto/bio/b_print.c
+++ b/crypto/bio/b_print.c
@@ -370,7 +370,7 @@ _dopr(char **sbuffer,
                        flags, min, max);
                 break;
             case 'p':
-                value = (long)va_arg(args, void *);
+                value = (size_t)va_arg(args, void *);
                 fmtint(sbuffer, buffer, &currlen, maxlen,
                        value, 16, min, max, flags | DP_F_NUM);
                 break;
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index 48e4036..e536eda 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -391,7 +391,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
         struct sockaddr_in6 sa_in6;
 # endif
     } server, client;
-    int s = INVALID_SOCKET, cs, addrlen;
+    int s = (int)INVALID_SOCKET, cs, addrlen;
     unsigned char ip[4];
     unsigned short port;
     char *str = NULL, *e;
@@ -400,10 +400,10 @@ int BIO_get_accept_socket(char *host, int bind_mode)
     int err_num;
 
     if (BIO_sock_init() != 1)
-        return (INVALID_SOCKET);
+        return ((int)INVALID_SOCKET);
 
     if ((str = BUF_strdup(host)) == NULL)
-        return (INVALID_SOCKET);
+        return ((int)INVALID_SOCKET);
 
     h = p = NULL;
     h = str;
@@ -503,7 +503,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
 
  again:
     s = socket(server.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL);
-    if (s == INVALID_SOCKET) {
+    if (s == (int)INVALID_SOCKET) {
         SYSerr(SYS_F_SOCKET, get_last_socket_error());
         ERR_add_error_data(3, "port='", host, "'");
         BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);
@@ -545,11 +545,11 @@ int BIO_get_accept_socket(char *host, int bind_mode)
                     goto err;
             }
             cs = socket(client.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL);
-            if (cs != INVALID_SOCKET) {
+            if (cs != (int)INVALID_SOCKET) {
                 int ii;
                 ii = connect(cs, &client.sa, addrlen);
                 closesocket(cs);
-                if (ii == INVALID_SOCKET) {
+                if (ii == (int)INVALID_SOCKET) {
                     bind_mode = BIO_BIND_REUSEADDR;
                     closesocket(s);
                     goto again;
@@ -573,16 +573,16 @@ int BIO_get_accept_socket(char *host, int bind_mode)
     ret = 1;
  err:
     OPENSSL_free(str);
-    if ((ret == 0) && (s != INVALID_SOCKET)) {
+    if ((ret == 0) && (s != (int)INVALID_SOCKET)) {
         closesocket(s);
-        s = INVALID_SOCKET;
+        s = (int)INVALID_SOCKET;
     }
     return (s);
 }
 
 int BIO_accept(int sock, char **addr)
 {
-    int ret = INVALID_SOCKET;
+    int ret = (int)INVALID_SOCKET;
     unsigned long l;
     unsigned short port;
     char *p;
@@ -631,7 +631,7 @@ int BIO_accept(int sock, char **addr)
         sa.len.i = (int)sa.len.s;
         /* use sa.len.i from this point */
     }
-    if (ret == INVALID_SOCKET) {
+    if (ret == (int)INVALID_SOCKET) {
         if (BIO_sock_should_retry(ret))
             return -2;
         SYSerr(SYS_F_ACCEPT, get_last_socket_error());
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index eba6e25..c549c87 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -123,7 +123,7 @@ static int acpt_new(BIO *bi)
     BIO_ACCEPT *ba;
 
     bi->init = 0;
-    bi->num = INVALID_SOCKET;
+    bi->num = (int)INVALID_SOCKET;
     bi->flags = 0;
     if ((ba = BIO_ACCEPT_new()) == NULL)
         return (0);
@@ -139,7 +139,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void)
 
     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
         return (NULL);
-    ret->accept_sock = INVALID_SOCKET;
+    ret->accept_sock = (int)INVALID_SOCKET;
     ret->bind_mode = BIO_BIND_NORMAL;
     return (ret);
 }
@@ -160,11 +160,11 @@ static void acpt_close_socket(BIO *bio)
     BIO_ACCEPT *c;
 
     c = (BIO_ACCEPT *)bio->ptr;
-    if (c->accept_sock != INVALID_SOCKET) {
+    if (c->accept_sock != (int)INVALID_SOCKET) {
         shutdown(c->accept_sock, 2);
         closesocket(c->accept_sock);
-        c->accept_sock = INVALID_SOCKET;
-        bio->num = INVALID_SOCKET;
+        c->accept_sock = (int)INVALID_SOCKET;
+        bio->num = (int)INVALID_SOCKET;
     }
 }
 
@@ -200,7 +200,7 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
             return (-1);
         }
         s = BIO_get_accept_socket(c->param_addr, c->bind_mode);
-        if (s == INVALID_SOCKET)
+        if (s == (int)INVALID_SOCKET)
             return (-1);
 
         if (c->accept_nbio) {
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index 0733a29..49b0f69 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -189,7 +189,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
             c->state = BIO_CONN_S_CREATE_SOCKET;
 
             ret = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-            if (ret == INVALID_SOCKET) {
+            if (ret == (int)INVALID_SOCKET) {
                 SYSerr(SYS_F_SOCKET, get_last_socket_error());
                 ERR_add_error_data(4, "host=", c->param_hostname,
                                    ":", c->param_port);
@@ -313,7 +313,7 @@ BIO_METHOD *BIO_s_connect(void)
 static int conn_new(BIO *bi)
 {
     bi->init = 0;
-    bi->num = INVALID_SOCKET;
+    bi->num = (int)INVALID_SOCKET;
     bi->flags = 0;
     if ((bi->ptr = (char *)BIO_CONNECT_new()) == NULL)
         return (0);
@@ -326,12 +326,12 @@ static void conn_close_socket(BIO *bio)
     BIO_CONNECT *c;
 
     c = (BIO_CONNECT *)bio->ptr;
-    if (bio->num != INVALID_SOCKET) {
+    if (bio->num != (int)INVALID_SOCKET) {
         /* Only do a shutdown if things were established */
         if (c->state == BIO_CONN_S_OK)
             shutdown(bio->num, 2);
         closesocket(bio->num);
-        bio->num = INVALID_SOCKET;
+        bio->num = (int)INVALID_SOCKET;
     }
 }
 
diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c
index f59ec7c..a86ea29 100644
--- a/crypto/bio/bss_log.c
+++ b/crypto/bio/bss_log.c
@@ -322,7 +322,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
         break;
     }
 
-    sprintf(pidbuf, "[%u] ", GetCurrentProcessId());
+    sprintf(pidbuf, "[%lu] ", GetCurrentProcessId());
     lpszStrings[0] = pidbuf;
     lpszStrings[1] = string;
 
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 10cc893..2cd1169 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -321,9 +321,9 @@ static IMPLEMENT_LHASH_COMP_FN(mem, MEM)
 
 static unsigned long mem_hash(const MEM *a)
 {
-    unsigned long ret;
+    size_t ret;
 
-    ret = (unsigned long)a->addr;
+    ret = (size_t)a->addr;
 
     ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
     return (ret);
@@ -661,8 +661,8 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
         bufp += strlen(bufp);
     }
 
-    BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
-                 m->num, (unsigned long)m->addr);
+    BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\n",
+                 m->num, m->addr);
     bufp += strlen(bufp);
 
     BIO_puts(l->bio, buf);
diff --git a/crypto/thr_id.c b/crypto/thr_id.c
index c391fc4..51088e4 100644
--- a/crypto/thr_id.c
+++ b/crypto/thr_id.c
@@ -146,7 +146,7 @@ void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
         /*
          * 'ptr' can be embedded in 'val' without loss of uniqueness
          */
-        id->val = (unsigned long)id->ptr;
+        id->val = (size_t)id->ptr;
         return;
     }
     /*
diff --git a/e_os.h b/e_os.h
index 8c4223b..6aa0f73 100644
--- a/e_os.h
+++ b/e_os.h
@@ -477,7 +477,9 @@ struct servent *PASCAL getservbyname(const char *, const char *);
 /*
  * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
  * the value constitutes an index in per-process table of limited size
- * and not a real pointer.
+ * and not a real pointer. And we also depend on fact that all processors
+ * Windows run on happen to be two's-complement, which allows to
+ * interchange INVALID_SOCKET and -1.
  */
 #     define socket(d,t,p)   ((int)socket(d,t,p))
 #     define accept(s,f,l)   ((int)accept(s,f,l))


More information about the openssl-commits mailing list