From: Tomas Mraz Date: Wed, 18 Jun 2025 08:50:27 +0000 (+0200) Subject: fuzz: Silence warnings on Win64 builds X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2482c68e5ce21bc36287103e1b527ab329a8a3d;p=thirdparty%2Fopenssl.git fuzz: Silence warnings on Win64 builds Reviewed-by: Saša Nedvědický Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/27806) --- diff --git a/fuzz/acert.c b/fuzz/acert.c index 7a1cf796aaa..4b8971c0e01 100644 --- a/fuzz/acert.c +++ b/fuzz/acert.c @@ -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()); diff --git a/fuzz/asn1.c b/fuzz/asn1.c index febb296ce92..1ae21c742e5 100644 --- a/fuzz/asn1.c +++ b/fuzz/asn1.c @@ -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) { /* diff --git a/fuzz/asn1parse.c b/fuzz/asn1parse.c index c25705cf730..81169a09dff 100644 --- a/fuzz/asn1parse.c +++ b/fuzz/asn1parse.c @@ -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; } diff --git a/fuzz/bignum.c b/fuzz/bignum.c index 08da6fb197f..5b1a8be8333 100644 --- a/fuzz/bignum.c +++ b/fuzz/bignum.c @@ -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 */ diff --git a/fuzz/bndiv.c b/fuzz/bndiv.c index d9467b5e8b4..f50a62f1700 100644 --- a/fuzz/bndiv.c +++ b/fuzz/bndiv.c @@ -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 */ diff --git a/fuzz/client.c b/fuzz/client.c index 1754add5096..0a074af03ab 100644 --- a/fuzz/client.c +++ b/fuzz/client.c @@ -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]; diff --git a/fuzz/cmp.c b/fuzz/cmp.c index 16d2fade225..72c6cf67abb 100644 --- a/fuzz/cmp.c +++ b/fuzz/cmp.c @@ -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()); diff --git a/fuzz/cms.c b/fuzz/cms.c index d464429a540..b4a17e4b2d1 100644 --- a/fuzz/cms.c +++ b/fuzz/cms.c @@ -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()); diff --git a/fuzz/conf.c b/fuzz/conf.c index 72e4b358fd8..35110630451 100644 --- a/fuzz/conf.c +++ b/fuzz/conf.c @@ -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); diff --git a/fuzz/crl.c b/fuzz/crl.c index 9e18dcb94b3..77aa34e6f51 100644 --- a/fuzz/crl.c +++ b/fuzz/crl.c @@ -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); diff --git a/fuzz/ct.c b/fuzz/ct.c index b37b11039c0..aa4e6c26f6a 100644 --- 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); diff --git a/fuzz/dtlsclient.c b/fuzz/dtlsclient.c index 0e239d991d8..8fa2d3faff0 100644 --- a/fuzz/dtlsclient.c +++ b/fuzz/dtlsclient.c @@ -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]; diff --git a/fuzz/dtlsserver.c b/fuzz/dtlsserver.c index 68ddb1e6e68..3e919c4c17e 100644 --- a/fuzz/dtlsserver.c +++ b/fuzz/dtlsserver.c @@ -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. */ diff --git a/fuzz/ml-dsa.c b/fuzz/ml-dsa.c index 1088f9d054f..7ca563343e3 100644 --- a/fuzz/ml-dsa.c +++ b/fuzz/ml-dsa.c @@ -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; /* diff --git a/fuzz/ml-kem.c b/fuzz/ml-kem.c index 7cf6e969603..0ad1f0fd514 100644 --- a/fuzz/ml-kem.c +++ b/fuzz/ml-kem.c @@ -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) { diff --git a/fuzz/pem.c b/fuzz/pem.c index cc2969f6bed..6ad815aa896 100644 --- a/fuzz/pem.c +++ b/fuzz/pem.c @@ -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); diff --git a/fuzz/provider.c b/fuzz/provider.c index 492d249c7db..3133861d342 100644 --- a/fuzz/provider.c +++ b/fuzz/provider.c @@ -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; diff --git a/fuzz/quic-client.c b/fuzz/quic-client.c index 9c20869abef..76408a37ced 100644 --- a/fuzz/quic-client.c +++ b/fuzz/quic-client.c @@ -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; } diff --git a/fuzz/quic-server.c b/fuzz/quic-server.c index 881f4585a3a..926f585c883 100644 --- a/fuzz/quic-server.c +++ b/fuzz/quic-server.c @@ -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; } diff --git a/fuzz/server.c b/fuzz/server.c index f51877a8c01..486aa33bfa5 100644 --- a/fuzz/server.c +++ b/fuzz/server.c @@ -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 { diff --git a/fuzz/smime.c b/fuzz/smime.c index 8a4deff2f64..a4593b67209 100644 --- a/fuzz/smime.c +++ b/fuzz/smime.c @@ -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) { diff --git a/fuzz/v3name.c b/fuzz/v3name.c index 2c7f94e17f8..ded2fe165fb 100644 --- a/fuzz/v3name.c +++ b/fuzz/v3name.c @@ -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); diff --git a/fuzz/x509.c b/fuzz/x509.c index 8db8556f278..70c4258d076 100644 --- a/fuzz/x509.c +++ b/fuzz/x509.c @@ -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)