]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
fuzz: Silence warnings on Win64 builds
authorTomas Mraz <tomas@openssl.org>
Wed, 18 Jun 2025 08:50:27 +0000 (10:50 +0200)
committerTomas Mraz <tomas@openssl.org>
Wed, 2 Jul 2025 15:26:26 +0000 (17:26 +0200)
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27806)

23 files changed:
fuzz/acert.c
fuzz/asn1.c
fuzz/asn1parse.c
fuzz/bignum.c
fuzz/bndiv.c
fuzz/client.c
fuzz/cmp.c
fuzz/cms.c
fuzz/conf.c
fuzz/crl.c
fuzz/ct.c
fuzz/dtlsclient.c
fuzz/dtlsserver.c
fuzz/ml-dsa.c
fuzz/ml-kem.c
fuzz/pem.c
fuzz/provider.c
fuzz/quic-client.c
fuzz/quic-server.c
fuzz/server.c
fuzz/smime.c
fuzz/v3name.c
fuzz/x509.c

index 7a1cf796aaaa0251dd773c506c58409ba7cc25dc..4b8971c0e01c9b8611751b62380a6b42a433e1d3 100644 (file)
@@ -27,7 +27,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     const unsigned char *p = buf;
     unsigned char *der = NULL;
 
-    X509_ACERT *acert = d2i_X509_ACERT(NULL, &p, len);
+    X509_ACERT *acert = d2i_X509_ACERT(NULL, &p, (long)len);
     if (acert != NULL) {
         BIO *bio = BIO_new(BIO_s_null());
 
index febb296ce924c5dc2aef6e8488b58463a63e2863..1ae21c742e55c372dabb7cc49d37e0d25ed9f4c6 100644 (file)
@@ -214,7 +214,7 @@ static ASN1_PCTX *pctx;
 #define DO_TEST(TYPE, D2I, I2D, PRINT) { \
     const unsigned char *p = buf; \
     unsigned char *der = NULL; \
-    TYPE *type = D2I(NULL, &p, len); \
+    TYPE *type = D2I(NULL, &p, (long)len); \
     \
     if (type != NULL) { \
         int len2; \
@@ -234,7 +234,7 @@ static ASN1_PCTX *pctx;
 #define DO_TEST_PRINT_OFFSET(TYPE, D2I, I2D, PRINT) { \
     const unsigned char *p = buf; \
     unsigned char *der = NULL; \
-    TYPE *type = D2I(NULL, &p, len); \
+    TYPE *type = D2I(NULL, &p, (long)len); \
     \
     if (type != NULL) { \
         BIO *bio = BIO_new(BIO_s_null()); \
@@ -252,7 +252,7 @@ static ASN1_PCTX *pctx;
 #define DO_TEST_PRINT_PCTX(TYPE, D2I, I2D, PRINT) { \
     const unsigned char *p = buf; \
     unsigned char *der = NULL; \
-    TYPE *type = D2I(NULL, &p, len); \
+    TYPE *type = D2I(NULL, &p, (long)len); \
     \
     if (type != NULL) { \
         BIO *bio = BIO_new(BIO_s_null()); \
@@ -271,7 +271,7 @@ static ASN1_PCTX *pctx;
 #define DO_TEST_NO_PRINT(TYPE, D2I, I2D) { \
     const unsigned char *p = buf; \
     unsigned char *der = NULL; \
-    TYPE *type = D2I(NULL, &p, len); \
+    TYPE *type = D2I(NULL, &p, (long)len); \
     \
     if (type != NULL) { \
         BIO *bio = BIO_new(BIO_s_null()); \
@@ -311,7 +311,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
         const uint8_t *b = buf;
         unsigned char *der = NULL;
         const ASN1_ITEM *i = ASN1_ITEM_ptr(item_type[n]);
-        ASN1_VALUE *o = ASN1_item_d2i(NULL, &b, len, i);
+        ASN1_VALUE *o = ASN1_item_d2i(NULL, &b, (long)len, i);
 
         if (o != NULL) {
             /*
index c25705cf730d87bfe7b3f75d39c6c2a1a37f6d1c..81169a09dffb9ce3dd1fd7acfbf87e7a126383ea 100644 (file)
@@ -34,7 +34,7 @@ int FuzzerInitialize(int *argc, char ***argv)
 
 int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 {
-    (void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
+    (void)ASN1_parse_dump(bio_out, buf, (long)len, 0, 0);
     ERR_clear_error();
     return 0;
 }
index 08da6fb197f5bea8b45757afc890f5be4d4bd61c..5b1a8be833360760bee700ce96d72970a34abdaf 100644 (file)
@@ -63,10 +63,10 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
         s3 = buf[0] & 4;
         ++buf;
     }
-    OPENSSL_assert(BN_bin2bn(buf, l1, b1) == b1);
+    OPENSSL_assert(BN_bin2bn(buf, (int)l1, b1) == b1);
     BN_set_negative(b1, s1);
-    OPENSSL_assert(BN_bin2bn(buf + l1, l2, b2) == b2);
-    OPENSSL_assert(BN_bin2bn(buf + l1 + l2, l3, b3) == b3);
+    OPENSSL_assert(BN_bin2bn(buf + l1, (int)l2, b2) == b2);
+    OPENSSL_assert(BN_bin2bn(buf + l1 + l2, (int)l3, b3) == b3);
     BN_set_negative(b3, s3);
 
     /* mod 0 is undefined */
index d9467b5e8b412cceecd539e744e4adcfc9891791..f50a62f17001b11481a760cc7d086e663f16ce2c 100644 (file)
@@ -69,9 +69,9 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
         ++buf;
         l2 = len - l1;
     }
-    OPENSSL_assert(BN_bin2bn(buf, l1, b1) == b1);
+    OPENSSL_assert(BN_bin2bn(buf, (int)l1, b1) == b1);
     BN_set_negative(b1, s1);
-    OPENSSL_assert(BN_bin2bn(buf + l1, l2, b2) == b2);
+    OPENSSL_assert(BN_bin2bn(buf + l1, (int)l2, b2) == b2);
     BN_set_negative(b2, s2);
 
     /* divide by 0 is an error */
index 1754add50967d0faaa5fbbd0194d7a99ecdce416..0a074af03abf21e6d8ffa8f0890f68ad487d7187 100644 (file)
@@ -60,7 +60,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     BIO *out;
     SSL_CTX *ctx;
 
-    if (len == 0)
+    if (len == 0 || len > INT_MAX)
         return 0;
 
     /* This only fuzzes the initial flow from the client so far. */
@@ -84,7 +84,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     }
     SSL_set_bio(client, in, out);
     SSL_set_connect_state(client);
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
     if (SSL_do_handshake(client) == 1) {
         /* Keep reading application data until error or EOF. */
         uint8_t tmp[1024];
index 16d2fade225d5554d23455cdeb928d556cb3789b..72c6cf67abbbae0fd4daa8964e14f7765df1296e 100644 (file)
@@ -172,11 +172,11 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     OSSL_CMP_MSG *msg;
     BIO *in;
 
-    if (len == 0)
+    if (len == 0 || len > INT_MAX)
         return 0;
 
     in = BIO_new(BIO_s_mem());
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
     msg = d2i_OSSL_CMP_MSG_bio(in, NULL);
     if (msg != NULL) {
         BIO *out = BIO_new(BIO_s_null());
index d464429a540792d4e6068bb0db8d15472b46e590..b4a17e4b2d14c7cf600b9d995aaa61bd0ccda988 100644 (file)
@@ -30,11 +30,11 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     CMS_ContentInfo *cms;
     BIO *in;
 
-    if (len == 0)
+    if (len == 0 || len > INT_MAX)
         return 0;
 
     in = BIO_new(BIO_s_mem());
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
     cms = d2i_CMS_bio(in, NULL);
     if (cms != NULL) {
         BIO *out = BIO_new(BIO_s_null());
index 72e4b358fd86f79547afd8d1f2f45e4184cc6bb5..35110630451bdbfe11abc0007385e3e914515ced 100644 (file)
@@ -29,12 +29,12 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     BIO *in;
     long eline;
 
-    if (len == 0)
+    if (len == 0 || len > INT_MAX)
         return 0;
 
     conf = NCONF_new(NULL);
     in = BIO_new(BIO_s_mem());
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
     NCONF_load_bio(conf, in, &eline);
     NCONF_free(conf);
     BIO_free(in);
index 9e18dcb94b36337ba977d87b2b9d253d8925f2de..77aa34e6f510d8a68cffbbd5fa9dd8496339b752 100644 (file)
@@ -26,7 +26,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     const unsigned char *p = buf;
     unsigned char *der = NULL;
 
-    X509_CRL *crl = d2i_X509_CRL(NULL, &p, len);
+    X509_CRL *crl = d2i_X509_CRL(NULL, &p, (long)len);
     if (crl != NULL) {
         BIO *bio = BIO_new(BIO_s_null());
         X509_CRL_print(bio, crl);
index b37b11039c0b99968283d8568b08e4bfe9c21342..aa4e6c26f6a50f13c4c8f3ec44a1a3caf1659b9e 100644 (file)
--- a/fuzz/ct.c
+++ b/fuzz/ct.c
@@ -29,7 +29,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 {
     const uint8_t **pp = &buf;
     unsigned char *der = NULL;
-    STACK_OF(SCT) *scts = d2i_SCT_LIST(NULL, pp, len);
+    STACK_OF(SCT) *scts = d2i_SCT_LIST(NULL, pp, (long)len);
     if (scts != NULL) {
         BIO *bio = BIO_new(BIO_s_null());
         SCT_LIST_print(scts, bio, 4, "\n", NULL);
index 0e239d991d80c2c41969dbfea2b28a58c04a5180..8fa2d3faff06a5283028d66af8bb423a0ecb19f8 100644 (file)
@@ -60,7 +60,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     BIO *out;
     SSL_CTX *ctx;
 
-    if (len == 0)
+    if (len == 0 || len > INT_MAX)
         return 0;
 
     /* This only fuzzes the initial flow from the client so far. */
@@ -84,7 +84,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     }
     SSL_set_bio(client, in, out);
     SSL_set_connect_state(client);
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
     if (SSL_do_handshake(client) == 1) {
         /* Keep reading application data until error or EOF. */
         uint8_t tmp[1024];
index 68ddb1e6e6834f32933ee0c421f0249e09d17495..3e919c4c17e86e7c41529d876f9ca5ac6783f1b5 100644 (file)
@@ -612,7 +612,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     DSA *dsakey = NULL;
 #endif
 
-    if (len < 2)
+    if (len < 2 || len > INT_MAX)
         return 0;
 
     /* This only fuzzes the initial flow from the client so far. */
@@ -702,7 +702,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     SSL_set_bio(server, in, out);
     SSL_set_accept_state(server);
 
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
 
     if (SSL_do_handshake(server) == 1) {
         /* Keep reading application data until error or EOF. */
index 1088f9d054fae5edcb00c9fb34308fe6f8a9ca50..7ca563343e342f787359398c4fedfb86a86ccdff 100644 (file)
@@ -198,7 +198,7 @@ static void create_ml_dsa_raw_key(uint8_t **buf, size_t *len,
      * typically much less (between 1 and 100 bytes) so use RAND_bytes here
      * instead
      */
-    if (!RAND_bytes(key, keylen))
+    if (!RAND_bytes(key, (int)keylen))
         return;
 
     /*
index 7cf6e96960348ea024bfdaaec7c91a4c959f307f..0ad1f0fd51407b4aff31ef671fa053e6224fb2c4 100644 (file)
@@ -166,7 +166,7 @@ static void create_mlkem_raw_key(uint8_t **buf, size_t *len,
      * buffers, but its typically much less (between 1 and 100 bytes)
      * so use RAND_bytes here instead
      */
-    if (!RAND_bytes(key, keylen))
+    if (!RAND_bytes(key, (int)keylen))
         return;
 
     /*
@@ -289,7 +289,7 @@ static void mlkem_encap_decap(uint8_t **buf, size_t *len, void *key1, void *in2,
         goto err;
     }
 
-    if (!RAND_bytes(genkey, genkey_len))
+    if (!RAND_bytes(genkey, (int)genkey_len))
         goto err;
 
     if (EVP_PKEY_encapsulate(ctx, wrapkey, &wrapkey_len, genkey, &genkey_len) <= 0) {
index cc2969f6bedb85493654ef89c7981a316f589def..6ad815aa896992971e65ea31f06487219f276a61 100644 (file)
@@ -27,16 +27,16 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     unsigned char *data = NULL;
     long outlen;
 
-    if (len <= 1)
+    if (len <= 1 || len > INT_MAX)
         return 0;
 
     in = BIO_new(BIO_s_mem());
-    OPENSSL_assert((size_t)BIO_write(in, buf + 1, len - 1) == len - 1);
+    OPENSSL_assert((size_t)BIO_write(in, buf + 1, (int)(len - 1)) == len - 1);
     if (PEM_read_bio_ex(in, &name, &header, &data, &outlen, buf[0]) == 1) {
-       /* Try to read all the data we get to see if allocated properly. */
-        BIO_write(in, name, strlen(name));
-       BIO_write(in, header, strlen(header));
-       BIO_write(in, data, outlen);
+        /* Try to read all the data we get to see if allocated properly. */
+        BIO_write(in, name, (int)strlen(name));
+        BIO_write(in, header, (int)strlen(header));
+        BIO_write(in, data, outlen);
     }
     if (buf[0] & PEM_FLAG_SECURE) {
         OPENSSL_secure_free(name);
index 492d249c7db339bf3a106c17b1efda1d86d905d1..3133861d342afec86074de949a31b2e811b5d78f 100644 (file)
@@ -214,7 +214,7 @@ static int read_octet_string(const uint8_t **buf, size_t *len, char **res)
 
     *res = (char *) *buf;
 
-    r = ptr - *buf;
+    r = (int)(ptr - *buf);
     *len -= r;
     *buf = ptr;
 
@@ -409,7 +409,8 @@ static int do_evp_cipher(const EVP_CIPHER *evp_cipher, const OSSL_PARAM param[])
         return 0;
     }
 
-    if (!EVP_EncryptUpdate(ctx, outbuf, &outlen, (const unsigned char *) intext, strlen(intext))) {
+    if (!EVP_EncryptUpdate(ctx, outbuf, &outlen, (const unsigned char *) intext,
+                           (int)strlen(intext))) {
         /* Error */
         EVP_CIPHER_CTX_free(ctx);
         return 0;
index 9c20869abefa68606d2e08985c6c6ffaf03da61f..76408a37ced1ffb6d79959acd5597d0562d74a28 100644 (file)
@@ -249,7 +249,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
             break;
 
         if (size > 0)
-            BIO_write(in, buf+2, size);
+            BIO_write(in, buf+2, (int)size);
         len -= size + 2;
         buf += size + 2;
     }
index 881f4585a3a3ab95cfdef1b1889de0e34bd68eae..926f585c883a59ddc0e8d321736d3ab68efa575b 100644 (file)
@@ -239,7 +239,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
             break;
 
         if (size > 0)
-            BIO_write(in, buf + 2, size);
+            BIO_write(in, buf + 2, (int)size);
         len -= size + 2;
         buf += size + 2;
     }
index f51877a8c011d533f2c94b1ce67bd16e6842ee86..486aa33bfa5d4e16a725fc32bcb4029620f35e47 100644 (file)
@@ -535,7 +535,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 #endif
     uint8_t opt;
 
-    if (len < 2)
+    if (len < 2 || len > INT_MAX)
         return 0;
 
     /* This only fuzzes the initial flow from the client so far. */
@@ -632,7 +632,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     opt = (uint8_t)buf[len-1];
     len--;
 
-    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
+    OPENSSL_assert((size_t)BIO_write(in, buf, (int)len) == len);
 
     if ((opt & 0x01) != 0) {
         do {
index 8a4deff2f64b19bc3ae0effadfbfc0918989be2b..a4593b672097d2d329fe3d239473ae90154fc48f 100644 (file)
@@ -21,7 +21,7 @@ int FuzzerInitialize(int *argc, char ***argv)
 
 int FuzzerTestOneInput(const uint8_t *buf, size_t len)
 {
-    BIO *b = BIO_new_mem_buf(buf, len);
+    BIO *b = BIO_new_mem_buf(buf, (int)len);
     PKCS7 *p7 = SMIME_read_PKCS7(b, NULL);
 
     if (p7 != NULL) {
index 2c7f94e17f8c8d0ed0427e15a08b5b659f01c200..ded2fe165fb6b121476525bac975b35989c14095 100644 (file)
@@ -28,9 +28,9 @@ int FuzzerTestOneInput(const uint8_t* data, size_t size){
      * We create two versions of each GENERAL_NAME so that we ensure when
      * we compare them they are always different pointers.
      */
-    namesa = d2i_GENERAL_NAME(NULL, &derp, size);
+    namesa = d2i_GENERAL_NAME(NULL, &derp, (long)size);
     derp = data;
-    namesb = d2i_GENERAL_NAME(NULL, &derp, size);
+    namesb = d2i_GENERAL_NAME(NULL, &derp, (long)size);
     GENERAL_NAME_cmp(namesa, namesb);
     if (namesa != NULL)
         GENERAL_NAME_free(namesa);
index 8db8556f278a2ffac93960f986c900daaefeb61b..70c4258d0762bbbe88f9a46f6ae948ab1dc5bb44 100644 (file)
@@ -47,7 +47,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     OCSP_BASICRESP *bs = NULL;
     OCSP_CERTID *id = NULL;
 
-    x509_1 = d2i_X509(NULL, &p, len);
+    x509_1 = d2i_X509(NULL, &p, (long)len);
     if (x509_1 == NULL)
         goto err;
 
@@ -65,17 +65,17 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len)
     OPENSSL_free(der);
 
     len = orig_len - (p - buf);
-    x509_2 = d2i_X509(NULL, &p, len);
+    x509_2 = d2i_X509(NULL, &p, (long)len);
     if (x509_2 == NULL)
         goto err;
 
     len = orig_len - (p - buf);
-    crl = d2i_X509_CRL(NULL, &p, len);
+    crl = d2i_X509_CRL(NULL, &p, (long)len);
     if (crl == NULL)
         goto err;
 
     len = orig_len - (p - buf);
-    resp = d2i_OCSP_RESPONSE(NULL, &p, len);
+    resp = d2i_OCSP_RESPONSE(NULL, &p, (long)len);
 
     store = X509_STORE_new();
     if (store == NULL)