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());
#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; \
#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()); \
#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()); \
#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()); \
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) {
/*
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;
}
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 */
++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 */
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. */
}
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];
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());
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());
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);
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);
{
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);
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. */
}
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];
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. */
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. */
* 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;
/*
* 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;
/*
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) {
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);
*res = (char *) *buf;
- r = ptr - *buf;
+ r = (int)(ptr - *buf);
*len -= r;
*buf = ptr;
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;
break;
if (size > 0)
- BIO_write(in, buf+2, size);
+ BIO_write(in, buf+2, (int)size);
len -= size + 2;
buf += size + 2;
}
break;
if (size > 0)
- BIO_write(in, buf + 2, size);
+ BIO_write(in, buf + 2, (int)size);
len -= size + 2;
buf += size + 2;
}
#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. */
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 {
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) {
* 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);
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;
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)