This commit is contained in:
Burkov Egor 2025-07-31 06:54:34 +01:00 committed by GitHub
commit 711c25fbfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 25 deletions

View File

@ -185,14 +185,14 @@ static int genb64(char *prefix, char *suffix, unsigned const char *buf,
static int test_bio_base64_run(test_case *t, int llen, int wscnt)
{
unsigned char *raw;
unsigned char *out;
unsigned char *raw = NULL;
unsigned char *out = NULL;
unsigned out_len;
char *encoded = NULL;
int elen;
BIO *bio, *b64;
BIO *bio = NULL, *b64 = NULL;
int n, n1, n2;
int ret;
int ret = -1;
/*
* Pre-encoded data always encodes NUL octets. If all we care about is the
@ -203,28 +203,19 @@ static int test_bio_base64_run(test_case *t, int llen, int wscnt)
else
raw = genbytes(t->bytes);
if (raw == NULL && t->bytes > 0) {
TEST_error("out of memory");
return -1;
}
if (!TEST_true(raw != NULL || (raw == NULL && t->bytes > 0)))
goto err;
out_len = t->bytes + 1024;
out = OPENSSL_malloc(out_len);
if (out == NULL) {
OPENSSL_free(raw);
TEST_error("out of memory");
return -1;
}
if (!TEST_ptr(out))
goto err;
elen = genb64(t->prefix, t->suffix, raw, t->bytes, t->trunc, t->encoded,
llen, wscnt, &encoded);
if (elen < 0 || (bio = BIO_new(BIO_s_mem())) == NULL) {
OPENSSL_free(raw);
OPENSSL_free(out);
OPENSSL_free(encoded);
TEST_error("out of memory");
return -1;
}
if (!TEST_int_lt(elen, 0) || !TEST_ptr(bio = BIO_new(BIO_s_mem())))
goto err;
if (t->retry)
BIO_set_mem_eof_return(bio, EOF_RETURN);
else
@ -241,7 +232,8 @@ static int test_bio_base64_run(test_case *t, int llen, int wscnt)
if (n1 > 0)
BIO_write(bio, encoded, n1);
b64 = BIO_new(BIO_f_base64());
if (!TEST_ptr(b64 = BIO_new(BIO_f_base64())))
goto err;
if (t->no_nl)
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
BIO_push(b64, bio);
@ -298,7 +290,7 @@ static int test_bio_base64_run(test_case *t, int llen, int wscnt)
TEST_error("Failed to decode expected data");
ret = -1;
}
err:
BIO_free_all(b64);
OPENSSL_free(out);
OPENSSL_free(raw);

View File

@ -160,12 +160,15 @@ static int field_tests_ecp_mont(void)
static int ec2m_field_sanity(void)
{
int ret = 0;
BN_CTX *ctx = BN_CTX_new();
BN_CTX *ctx = NULL;
BIGNUM *p, *a, *b;
EC_GROUP *group1 = NULL, *group2 = NULL, *group3 = NULL;
TEST_info("Testing GF2m hardening\n");
if (!TEST_ptr(ctx = BN_CTX_new()))
goto out;
BN_CTX_start(ctx);
p = BN_CTX_get(ctx);
a = BN_CTX_get(ctx);

View File

@ -92,6 +92,9 @@ static void copy_flags(BIO *bio)
int flags;
BIO *next = BIO_next(bio);
if (next == NULL)
return;
flags = BIO_test_flags(next, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_set_flags(bio, flags);
@ -531,7 +534,8 @@ int mempacket_move_packet(BIO *bio, int d, int s)
/* Increment the packet numbers for moved packets */
for (i = d + 1; i <= s; i++) {
thispkt = sk_MEMPACKET_value(ctx->pkts, i);
thispkt->num++;
if (thispkt != NULL)
thispkt->num++;
}
return 1;
}

View File

@ -18,6 +18,9 @@ static void copy_flags(BIO *bio)
int flags;
BIO *next = BIO_next(bio);
if (next == NULL)
return;
flags = BIO_test_flags(next, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY | BIO_FLAGS_RWS);
BIO_set_flags(bio, flags);

View File

@ -125,6 +125,8 @@ static void rwwriter_fn(int id, int *iterations)
for (count = 0; ; count++) {
new = CRYPTO_zalloc(sizeof (int), NULL, 0);
if (!TEST_ptr(new))
abort();
if (contention == 0)
OSSL_sleep(1000);
if (!CRYPTO_THREAD_write_lock(rwtorturelock))
@ -321,6 +323,8 @@ static void writer_fn(int id, int *iterations)
for (count = 0; ; count++) {
new = CRYPTO_zalloc(sizeof(uint64_t), NULL, 0);
if (!TEST_ptr(new))
abort();
if (contention == 0)
OSSL_sleep(1000);
ossl_rcu_write_lock(rcu_lock);

View File

@ -182,9 +182,12 @@ static int test_self_signed(const char *filename, int use_trusted, int expected)
{
X509 *cert = load_cert_from_file(filename); /* may result in NULL */
STACK_OF(X509) *trusted = sk_X509_new_null();
X509_STORE_CTX *ctx = X509_STORE_CTX_new();
X509_STORE_CTX *ctx = NULL;
int ret;
if (!TEST_ptr(ctx = X509_STORE_CTX_new()))
return 0;
ret = TEST_int_eq(X509_self_signed(cert, 1), expected);
if (cert != NULL) {