ATTICerr(0, ERR_R_UI_LIB);
pass = NULL;
} else if (UI_add_input_string(ui, prompt, UI_INPUT_FLAG_DEFAULT_PWD,
- pass, 0, maxsize - 1) <= 0) {
+ pass, 0, (int)(maxsize - 1)) <= 0) {
ATTICerr(0, ERR_R_UI_LIB);
pass = NULL;
} else {
pass_data->prompt_desc, pass_data->prompt_info,
pass_data->data);
- return pass == NULL ? 0 : strlen(pass);
+ return pass == NULL ? 0 : (int)strlen(pass);
}
/*
*/
static int check_suffix(const char *str, const char *suffix)
{
- int str_len = strlen(str);
- int suffix_len = strlen(suffix) + 1;
+ int str_len = (int)strlen(str);
+ int suffix_len = (int)(strlen(suffix) + 1);
const char *p = NULL;
if (suffix_len >= str_len)
if (*p != ' '
|| strcmp(p + 1, suffix) != 0)
return -1;
- return p - str;
+ return (int)(p - str);
}
/*
/* Initial parsing */
PKCS12 *p12;
- if (pem_name != NULL)
+ if (pem_name != NULL || len > LONG_MAX)
/* No match, there is no PEM PKCS12 tag */
return NULL;
- if ((p12 = d2i_PKCS12(NULL, &blob, len)) != NULL) {
+ if ((p12 = d2i_PKCS12(NULL, &blob, (long)len)) != NULL) {
char *pass = NULL;
char tpass[PEM_BUFSIZE];
EVP_PKEY *pkey = NULL;
ATTICerr(0, ATTIC_R_PASSPHRASE_CALLBACK_ERROR);
goto p12_end;
}
- if (!PKCS12_verify_mac(p12, pass, strlen(pass))) {
+ if (!PKCS12_verify_mac(p12, pass, (int)strlen(pass))) {
ATTICerr(0, ATTIC_R_ERROR_VERIFYING_PKCS12_MAC);
goto p12_end;
}
*matchcount = 1;
}
- if ((p8 = d2i_X509_SIG(NULL, &blob, len)) == NULL)
+ if (len > LONG_MAX || (p8 = d2i_X509_SIG(NULL, &blob, (long)len)) == NULL)
return NULL;
*matchcount = 1;
}
X509_SIG_get0(p8, &dalg, &doct);
- if (!PKCS12_pbe_crypt(dalg, pass, strlen(pass), doct->data, doct->length,
+ if (!PKCS12_pbe_crypt(dalg, pass, (int)strlen(pass),
+ doct->data, doct->length,
&new_data, &new_data_len, 0))
goto nop8;
EVP_PKEY *pkey = NULL;
const EVP_PKEY_ASN1_METHOD *ameth = NULL;
+ if (len > LONG_MAX)
+ return NULL;
if (pem_name != NULL) {
if (strcmp(pem_name, PEM_STRING_PKCS8INF) == 0) {
PKCS8_PRIV_KEY_INFO *p8inf =
- d2i_PKCS8_PRIV_KEY_INFO(NULL, &blob, len);
+ d2i_PKCS8_PRIV_KEY_INFO(NULL, &blob, (long)len);
*matchcount = 1;
if (p8inf != NULL)
&& EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL,
ameth)) {
*matchcount = 1;
- pkey = d2i_PrivateKey_ex(pkey_id, NULL, &blob, len,
+ pkey = d2i_PrivateKey_ex(pkey_id, NULL, &blob, (long)len,
libctx, propq);
}
}
ERR_set_mark(); /* prevent flooding error queue */
tmp_pkey = d2i_PrivateKey_ex(pkey_id, NULL,
- &tmp_blob, len,
+ &tmp_blob, (long)len,
libctx, propq);
if (tmp_pkey != NULL) {
if (pkey != NULL)
continue;
ERR_set_mark(); /* prevent flooding error queue */
- tmp_pkey = d2i_PrivateKey_ex(pkey_id, NULL, &tmp_blob, len,
+ tmp_pkey = d2i_PrivateKey_ex(pkey_id, NULL, &tmp_blob, (long)len,
libctx, propq);
if (tmp_pkey != NULL) {
if (pkey != NULL)
*matchcount = 1;
}
- if ((pkey = d2i_PUBKEY(NULL, &blob, len)) != NULL) {
+ if (len > LONG_MAX || (pkey = d2i_PUBKEY(NULL, &blob, (long)len)) != NULL) {
*matchcount = 1;
store_info = OSSL_STORE_INFO_new_PUBKEY(pkey);
}
EVP_PKEY *pkey = NULL;
const EVP_PKEY_ASN1_METHOD *ameth = NULL;
+ if (len > LONG_MAX)
+ return NULL;
if (pem_name != NULL) {
int slen;
int pkey_id;
&& EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL,
ameth)) {
*matchcount = 1;
- pkey = d2i_KeyParams(pkey_id, NULL, &blob, len);
+ pkey = d2i_KeyParams(pkey_id, NULL, &blob, (long)len);
}
} else {
int i;
ERR_set_mark(); /* prevent flooding error queue */
- tmp_pkey = d2i_KeyParams(pkey_id, NULL, &tmp_blob, len);
+ tmp_pkey = d2i_KeyParams(pkey_id, NULL, &tmp_blob, (long)len);
if (tmp_pkey != NULL) {
if (pkey != NULL)
*/
int ignore_trusted = 1;
+ if (len > LONG_MAX)
+ return NULL;
if (pem_name != NULL) {
if (strcmp(pem_name, PEM_STRING_X509_TRUSTED) == 0)
ignore_trusted = 0;
if (cert == NULL)
return NULL;
- if ((d2i_X509_AUX(&cert, &blob, len)) != NULL
- || (ignore_trusted && (d2i_X509(&cert, &blob, len)) != NULL)) {
+ if ((d2i_X509_AUX(&cert, &blob, (long)len)) != NULL
+ || (ignore_trusted && (d2i_X509(&cert, &blob, (long)len)) != NULL)) {
*matchcount = 1;
store_info = OSSL_STORE_INFO_new_CERT(cert);
}
OSSL_STORE_INFO *store_info = NULL;
X509_CRL *crl = NULL;
+ if (len > LONG_MAX)
+ return NULL;
if (pem_name != NULL) {
if (strcmp(pem_name, PEM_STRING_X509_CRL) != 0)
/* No match */
*matchcount = 1;
}
- if ((crl = d2i_X509_CRL(NULL, &blob, len)) != NULL) {
+ if ((crl = d2i_X509_CRL(NULL, &blob, (long)len)) != NULL) {
*matchcount = 1;
store_info = OSSL_STORE_INFO_new_CRL(crl);
}
assert(data != NULL);
{
const char *pathsep = ossl_ends_with_dirsep(ctx->uri) ? "" : "/";
- long calculated_length = strlen(ctx->uri) + strlen(pathsep)
- + strlen(name) + 1 /* \0 */;
+ long calculated_length = (long)(strlen(ctx->uri) + strlen(pathsep)
+ + strlen(name) + 1 /* \0 */);
*data = OPENSSL_zalloc(calculated_length);
if (*data == NULL)