apps: Silence warnings on Win64 builds

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)
This commit is contained in:
Tomas Mraz 2025-06-17 20:08:49 +02:00
parent a0fcbcb282
commit c62cd07d14
21 changed files with 67 additions and 63 deletions

View File

@ -707,7 +707,7 @@ end_of_options:
goto end;
}
p = pp[DB_serial];
j = strlen(p);
j = (int)strlen(p);
if (*p == '-') {
p++;
j--;
@ -2406,9 +2406,9 @@ static char *make_revocation_str(REVINFO_TYPE rev_type, const char *rev_arg)
i = revtm->length + 1;
if (reason)
i += strlen(reason) + 1;
i += (int)(strlen(reason) + 1);
if (other)
i += strlen(other) + 1;
i += (int)(strlen(other) + 1);
str = app_malloc(i, "revocation reason");
OPENSSL_strlcpy(str, (char *)revtm->data, i);

View File

@ -1145,7 +1145,7 @@ static OSSL_CMP_SRV_CTX *setup_srv_ctx(ENGINE *engine)
}
} else {
if (!OSSL_CMP_CTX_set1_referenceValue(ctx, (unsigned char *)opt_srv_ref,
strlen(opt_srv_ref)))
(int)strlen(opt_srv_ref)))
goto err;
}
@ -1156,7 +1156,7 @@ static OSSL_CMP_SRV_CTX *setup_srv_ctx(ENGINE *engine)
if (pass_str != NULL) {
cleanse(opt_srv_secret);
res = OSSL_CMP_CTX_set1_secretValue(ctx, (unsigned char *)pass_str,
strlen(pass_str));
(int)strlen(pass_str));
clear_free(pass_str);
if (res == 0)
goto err;
@ -1550,7 +1550,7 @@ static int setup_protection_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
cleanse(opt_secret);
res = OSSL_CMP_CTX_set1_secretValue(ctx,
(unsigned char *)pass_string,
strlen(pass_string));
(int)strlen(pass_string));
clear_free(pass_string);
if (res == 0)
return 0;
@ -1560,7 +1560,7 @@ static int setup_protection_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
}
if (opt_ref != NULL
&& !OSSL_CMP_CTX_set1_referenceValue(ctx, (unsigned char *)opt_ref,
strlen(opt_ref)))
(int)strlen(opt_ref)))
return 0;
if (opt_key != NULL) {

View File

@ -576,7 +576,7 @@ static void print_out(BIO *out, unsigned char *buf, size_t len,
int i, backslash = 0;
if (binout) {
BIO_write(out, buf, len);
BIO_write(out, buf, (int)len);
} else if (sep == 2) {
file = newline_escape_filename(file, &backslash);

View File

@ -582,7 +582,7 @@ int enc_main(int argc, char **argv)
/* not needed if HASH_UPDATE() is fixed : */
int islen = (sptr != NULL ? saltlen : 0);
if (!PKCS5_PBKDF2_HMAC(str, str_len, sptr, islen,
if (!PKCS5_PBKDF2_HMAC(str, (int)str_len, sptr, islen,
iter, dgst, iklen+ivlen, tmpkeyiv)) {
BIO_printf(bio_err, "PKCS5_PBKDF2_HMAC failed\n");
goto end;
@ -596,7 +596,7 @@ int enc_main(int argc, char **argv)
"deprecated key derivation used.\n"
"Using -iter or -pbkdf2 would be better.\n");
if (!EVP_BytesToKey(cipher, dgst, sptr,
(unsigned char *)str, str_len,
(unsigned char *)str, (int)str_len,
1, key, iv)) {
BIO_printf(bio_err, "EVP_BytesToKey failed\n");
goto end;
@ -825,7 +825,7 @@ static int set_hex(const char *in, unsigned char *out, int size)
unsigned char j;
i = size * 2;
n = strlen(in);
n = (int)strlen(in);
if (n > i) {
BIO_printf(bio_err, "hex string is too long, ignoring excess\n");
n = i; /* ignore exceeding part */

View File

@ -55,14 +55,14 @@ const OPTIONS engine_options[] = {
static int append_buf(char **buf, int *size, const char *s)
{
const int expand = 256;
int len = strlen(s) + 1;
int len = (int)(strlen(s) + 1);
char *p = *buf;
if (p == NULL) {
*size = ((len + expand - 1) / expand) * expand;
p = *buf = app_malloc(*size, "engine buffer");
} else {
const int blen = strlen(p);
const int blen = (int)strlen(p);
if (blen > 0)
len += 2 + blen;

View File

@ -853,7 +853,7 @@ int fipsinstall_main(int argc, char **argv)
/* Calculate the MAC for the indicator status - it may not be used */
mem_bio = BIO_new_mem_buf((const void *)INSTALL_STATUS_VAL,
strlen(INSTALL_STATUS_VAL));
(int)strlen(INSTALL_STATUS_VAL));
if (mem_bio == NULL) {
BIO_printf(bio_err, "Unable to create memory BIO\n");
goto end;

View File

@ -75,7 +75,7 @@ int kdf_main(int argc, char **argv)
char *prog, *hexout = NULL;
const char *outfile = NULL;
unsigned char *dkm_bytes = NULL;
size_t dkm_len = 0;
int dkm_len = 0;
BIO *out = NULL;
EVP_KDF *kdf = NULL;
EVP_KDF_CTX *ctx = NULL;
@ -96,7 +96,7 @@ opthelp:
out_bin = 1;
break;
case OPT_KEYLEN:
dkm_len = (size_t)atoi(opt_arg());
dkm_len = atoi(opt_arg());
break;
case OPT_OUT:
outfile = opt_arg();

View File

@ -847,7 +847,7 @@ static void list_tls_groups(int version, int all)
{
SSL_CTX *ctx = NULL;
STACK_OF(OPENSSL_CSTRING) *groups;
size_t i, num;
int i, num;
if ((groups = sk_OPENSSL_CSTRING_new_null()) == NULL) {
BIO_printf(bio_err, "ERROR: Memory allocation\n");

View File

@ -212,7 +212,7 @@ opthelp:
}
if (out_bin) {
BIO_write(out, buf, len);
BIO_write(out, buf, (int)len);
} else {
for (i = 0; i < (int)len; ++i)
BIO_printf(out, "%02X", buf[i]);

View File

@ -132,8 +132,10 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
BIO_printf(bio_err, "ERROR: writing when tracing not started\n");
return 0;
}
if (cnt > INT_MAX)
cnt = INT_MAX;
ret = BIO_write(trace_data->bio, buf, cnt);
ret = BIO_write(trace_data->bio, buf, (int)cnt);
break;
case OSSL_TRACE_CTRL_END:
if (!trace_data->ingroup) {

View File

@ -241,7 +241,7 @@ int passwd_main(int argc, char **argv)
passwds = passwds_static;
if (in == NULL) {
if (EVP_read_pw_string
(passwd_malloc, passwd_malloc_size, "Password: ",
(passwd_malloc, (int)passwd_malloc_size, "Password: ",
!(passed_salt || in_noverify)) != 0)
goto end;
}
@ -269,7 +269,7 @@ int passwd_main(int argc, char **argv)
assert(passwd != NULL);
do {
int r = BIO_gets(in, passwd, pw_maxlen + 1);
int r = BIO_gets(in, passwd, (int)(pw_maxlen + 1));
if (r > 0) {
char *c = (strchr(passwd, '\n'));
if (c != NULL) {
@ -395,14 +395,14 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|| !EVP_DigestFinal_ex(md2, buf, NULL))
goto err;
for (i = passwd_len; i > sizeof(buf); i -= sizeof(buf)) {
for (i = (unsigned int)passwd_len; i > sizeof(buf); i -= sizeof(buf)) {
if (!EVP_DigestUpdate(md, buf, sizeof(buf)))
goto err;
}
if (!EVP_DigestUpdate(md, buf, i))
goto err;
n = passwd_len;
n = (int)passwd_len;
while (n) {
if (!EVP_DigestUpdate(md, (n & 1) ? "\0" : passwd, 1))
goto err;
@ -797,7 +797,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
if (*salt_malloc_p == NULL)
*salt_p = *salt_malloc_p = app_malloc(saltlen + 1, "salt buffer");
if (RAND_bytes((unsigned char *)*salt_p, saltlen) <= 0)
if (RAND_bytes((unsigned char *)*salt_p, (int)saltlen) <= 0)
goto end;
for (i = 0; i < saltlen; i++)

View File

@ -284,7 +284,7 @@ int pkcs8_main(int argc, char **argv)
BIO_printf(bio_err, "Password required\n");
goto end;
}
p8 = PKCS8_set0_pbe(p8pass, strlen(p8pass), p8inf, pbe);
p8 = PKCS8_set0_pbe(p8pass, (int)strlen(p8pass), p8inf, pbe);
if (p8 == NULL) {
X509_ALGOR_free(pbe);
BIO_printf(bio_err, "Error encrypting key\n");
@ -344,7 +344,7 @@ int pkcs8_main(int argc, char **argv)
BIO_printf(bio_err, "Password required\n");
goto end;
}
p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
p8inf = PKCS8_decrypt(p8, p8pass, (int)strlen(p8pass));
}
if (p8inf == NULL) {

View File

@ -550,14 +550,14 @@ int pkeyutl_main(int argc, char **argv)
if (rawin) {
/* rawin allocates the buffer in do_raw_keyop() */
rv = do_raw_keyop(pkey_op, mctx, pkey, in, filesize, NULL, 0,
&buf_out, (size_t *)&buf_outlen);
&buf_out, &buf_outlen);
} else {
if (kdflen != 0) {
buf_outlen = kdflen;
rv = 1;
} else {
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
buf_in, (size_t)buf_inlen, NULL, (size_t *)&secretlen);
rv = do_keyop(ctx, pkey_op, NULL, &buf_outlen,
buf_in, (size_t)buf_inlen, NULL, &secretlen);
}
if (rv > 0
&& (secretlen > 0 || (pkey_op != EVP_PKEY_OP_ENCAPSULATE
@ -568,8 +568,8 @@ int pkeyutl_main(int argc, char **argv)
if (secretlen > 0)
secret = app_malloc(secretlen, "secret output");
rv = do_keyop(ctx, pkey_op,
buf_out, (size_t *)&buf_outlen,
buf_in, (size_t)buf_inlen, secret, (size_t *)&secretlen);
buf_out, &buf_outlen,
buf_in, (size_t)buf_inlen, secret, &secretlen);
}
}
if (rv <= 0) {
@ -583,16 +583,16 @@ int pkeyutl_main(int argc, char **argv)
ret = 0;
if (asn1parse) {
if (!ASN1_parse_dump(out, buf_out, buf_outlen, 1, -1))
if (!ASN1_parse_dump(out, buf_out, (long)buf_outlen, 1, -1))
ERR_print_errors(bio_err); /* but still return success */
} else if (hexdump) {
BIO_dump(out, (char *)buf_out, buf_outlen);
BIO_dump(out, (char *)buf_out, (int)buf_outlen);
} else {
BIO_write(out, buf_out, buf_outlen);
BIO_write(out, buf_out, (int)buf_outlen);
}
/* Backwards compatible decap output fallback */
if (secretlen > 0)
BIO_write(secout ? secout : out, secret, secretlen);
BIO_write(secout ? secout : out, secret, (int)secretlen);
end:
if (ret != 0)

View File

@ -173,7 +173,6 @@ opthelp:
} else {
for ( ; *argv; argv++) {
int bytes_read = 0;
int valid_digits_length = 0;
if (!in_file) {
process_num(argv[0], hex);
@ -185,6 +184,8 @@ opthelp:
}
while ((bytes_read = BIO_get_line(in, file_read_buf, BUFSIZE)) > 0) {
size_t valid_digits_length;
/* Number is too long. Discard remainder of the line */
if (bytes_read == BUFSIZE - 1 && file_read_buf[BUFSIZE - 2] != '\n') {
BIO_printf(bio_err, "Value in %s is over the maximum size (%d digits)\n",

View File

@ -1418,7 +1418,7 @@ static int build_data(char *text, const char *def, char *value,
return 1;
}
i = strlen(buf);
i = (int)strlen(buf);
if (buf[i - 1] != '\n') {
BIO_printf(bio_err, "Missing newline at end of input\n");
return 0;
@ -1512,9 +1512,9 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
int len;
if (p != NULL)
len = p - gstr;
len = (int)(p - gstr);
else
len = strlen(gstr);
len = (int)strlen(gstr);
if (strncmp(gstr, "param", len) == 0) {
expect_paramfile = 1;

View File

@ -271,13 +271,13 @@ int rsautl_main(int argc, char **argv)
}
ret = 0;
if (asn1parse) {
if (!ASN1_parse_dump(out, rsa_out, rsa_outlen, 1, -1)) {
if (!ASN1_parse_dump(out, rsa_out, (long)rsa_outlen, 1, -1)) {
ERR_print_errors(bio_err);
}
} else if (hexdump) {
BIO_dump(out, (char *)rsa_out, rsa_outlen);
BIO_dump(out, (char *)rsa_out, (int)rsa_outlen);
} else {
BIO_write(out, rsa_out, rsa_outlen);
BIO_write(out, rsa_out, (int)rsa_outlen);
}
end:
EVP_PKEY_CTX_free(ctx);

View File

@ -311,7 +311,8 @@ static int next_proto_cb(SSL *s, unsigned char **out, unsigned char *outlen,
}
ctx->status =
SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);
SSL_select_next_proto(out, outlen, in, inlen,
ctx->data, (unsigned int)ctx->len);
return SSL_TLSEXT_ERR_OK;
}
#endif /* ndef OPENSSL_NO_NEXTPROTONEG */
@ -333,7 +334,7 @@ static int serverinfo_cli_parse_cb(SSL *s, unsigned int ext_type,
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
ext_type);
PEM_write_bio(bio_c_out, pem_name, "", ext_buf, 4 + inlen);
PEM_write_bio(bio_c_out, pem_name, "", ext_buf, (long)(4 + inlen));
return 1;
}
@ -1482,7 +1483,7 @@ int s_client_main(int argc, char **argv)
break;
case OPT_SERVERINFO:
p = opt_arg();
len = strlen(p);
len = (int)strlen(p);
for (start = 0, i = 0; i <= len; ++i) {
if (i == len || p[i] == ',') {
serverinfo_types[serverinfo_count] = atoi(p + start);
@ -1965,7 +1966,7 @@ int s_client_main(int argc, char **argv)
goto end;
}
/* Returns 0 on success! */
if (SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len) != 0) {
if (SSL_CTX_set_alpn_protos(ctx, alpn, (unsigned int)alpn_len) != 0) {
BIO_printf(bio_err, "Error setting ALPN\n");
goto end;
}
@ -3687,7 +3688,7 @@ static int ldap_ExtendedResponse_parse(const char *buf, long rem)
/* pull SEQUENCE */
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_CONSTRUCTED || tag != V_ASN1_SEQUENCE ||
(rem = end - cur, len > rem)) {
(rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "Unexpected LDAP response\n");
goto end;
}
@ -3697,7 +3698,7 @@ static int ldap_ExtendedResponse_parse(const char *buf, long rem)
/* pull MessageID */
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_UNIVERSAL || tag != V_ASN1_INTEGER ||
(rem = end - cur, len > rem)) {
(rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "No MessageID\n");
goto end;
}
@ -3705,7 +3706,7 @@ static int ldap_ExtendedResponse_parse(const char *buf, long rem)
cur += len; /* shall we check for MessageId match or just skip? */
/* pull [APPLICATION 24] */
rem = end - cur;
rem = (long)(end - cur);
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_CONSTRUCTED || xclass != V_ASN1_APPLICATION ||
tag != 24) {
@ -3714,10 +3715,10 @@ static int ldap_ExtendedResponse_parse(const char *buf, long rem)
}
/* pull resultCode */
rem = end - cur;
rem = (long)(end - cur);
inf = ASN1_get_object(&cur, &len, &tag, &xclass, rem);
if (inf != V_ASN1_UNIVERSAL || tag != V_ASN1_ENUMERATED || len == 0 ||
(rem = end - cur, len > rem)) {
(rem = (long)(end - cur), len > rem)) {
BIO_printf(bio_err, "Not LDAPResult\n");
goto end;
}

View File

@ -660,7 +660,7 @@ static int next_proto_cb(SSL *s, const unsigned char **data,
tlsextnextprotoctx *next_proto = arg;
*data = next_proto->data;
*len = next_proto->len;
*len = (unsigned int)next_proto->len;
return SSL_TLSEXT_ERR_OK;
}
@ -691,8 +691,8 @@ static int alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen,
}
if (SSL_select_next_proto
((unsigned char **)out, outlen, alpn_ctx->data, alpn_ctx->len, in,
inlen) != OPENSSL_NPN_NEGOTIATED) {
((unsigned char **)out, outlen, alpn_ctx->data,
(unsigned int)alpn_ctx->len, in, inlen) != OPENSSL_NPN_NEGOTIATED) {
return SSL_TLSEXT_ERR_ALERT_FATAL;
}
@ -2476,7 +2476,7 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
if (context != NULL
&& !SSL_set_session_id_context(con, context,
strlen((char *)context))) {
(unsigned int)strlen((char *)context))) {
BIO_printf(bio_err, "Error setting session id context\n");
ret = -1;
goto err;
@ -3205,7 +3205,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
if (context != NULL
&& !SSL_set_session_id_context(con, context,
strlen((char *)context))) {
(unsigned int)strlen((char *)context))) {
SSL_free(con);
goto err;
}
@ -3518,7 +3518,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
BIO_printf(bio_err, "FILE:%s\n", p);
if (www == 2) {
i = strlen(p);
i = (int)strlen(p);
if (((i > 5) && (strcmp(&(p[i - 5]), ".html") == 0)) ||
((i > 4) && (strcmp(&(p[i - 4]), ".php") == 0)) ||
((i > 4) && (strcmp(&(p[i - 4]), ".htm") == 0)))
@ -3667,7 +3667,7 @@ static int rev_body(int s, int stype, int prot, unsigned char *context)
}
if (context != NULL
&& !SSL_set_session_id_context(con, context,
strlen((char *)context))) {
(unsigned int)strlen((char *)context))) {
SSL_free(con);
ERR_print_errors(bio_err);
goto err;
@ -3798,7 +3798,7 @@ static int generate_session_id(SSL *ssl, unsigned char *id,
unsigned int *id_len)
{
unsigned int count = 0;
unsigned int session_id_prefix_len = strlen(session_id_prefix);
unsigned int session_id_prefix_len = (unsigned int)strlen(session_id_prefix);
do {
if (RAND_bytes(id, *id_len) <= 0)

View File

@ -114,7 +114,7 @@ int sess_id_main(int argc, char **argv)
goto end;
}
if (!SSL_SESSION_set1_id_context(x, (unsigned char *)context,
ctx_len)) {
(unsigned int)ctx_len)) {
BIO_printf(bio_err, "Error setting id context\n");
goto end;
}

View File

@ -2727,7 +2727,7 @@ int speed_main(int argc, char **argv)
if (doit[D_HMAC]) {
static const char hmac_key[] = "This is a key...";
int len = strlen(hmac_key);
int len = (int)strlen(hmac_key);
size_t hmac_name_len = sizeof("hmac()") + strlen(evp_mac_mdname);
OSSL_PARAM params[3];
@ -5128,7 +5128,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
aad[12] = (unsigned char)(len);
pad = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_TLS1_AAD,
EVP_AEAD_TLS1_AAD_LEN, aad);
ciph_success = EVP_Cipher(ctx, out, inp, len + pad);
ciph_success = EVP_Cipher(ctx, out, inp, (unsigned int)(len + pad));
}
}
d = Time_F(STOP);

View File

@ -1258,7 +1258,7 @@ static int parse_ext_names(char *names, const char **result)
int cnt = 0, len = 0;
p = q = names;
len = strlen(names);
len = (int)strlen(names);
while (q - names <= len) {
if (*q != ',' && *q != '\0') {