Cast socklen_t to size_t in assert comparison
authorJ.W. Jagersma <jwjagersma@gmail.com>
Sat, 1 Oct 2022 16:44:38 +0000 (18:44 +0200)
committerHugo Landau <hlandau@openssl.org>
Mon, 14 Nov 2022 07:47:53 +0000 (07:47 +0000)
This causes a warning otherwise when socklen_t is signed (Watt32).

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19322)

crypto/bio/bss_dgram.c

index 97600e4cd394bf80da68a4d10e0bea2ffbe66220..6ec43b1bc5b9f7169eeb63584fecca5a65bd9da5 100644 (file)
@@ -765,7 +765,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
                 ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
                                "calling getsockopt()");
             } else {
-                OPENSSL_assert(sz <= sizeof(struct timeval));
+                OPENSSL_assert((size_t)sz <= sizeof(struct timeval));
                 ret = (int)sz;
             }
 #  endif
@@ -816,7 +816,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
                 ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
                                "calling getsockopt()");
             } else {
-                OPENSSL_assert(sz <= sizeof(struct timeval));
+                OPENSSL_assert((size_t)sz <= sizeof(struct timeval));
                 ret = (int)sz;
             }
 #  endif