/*
- * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
failures++;
err:
- if (buff != NULL)
- OPENSSL_free(buff);
- if (drbg != NULL) {
- RAND_DRBG_uninstantiate(drbg);
- RAND_DRBG_free(drbg);
- }
+ OPENSSL_free(buff);
+ RAND_DRBG_uninstantiate(drbg);
+ RAND_DRBG_free(drbg);
return failures == 0;
}
failures++;
err:
- if (buff != NULL)
- OPENSSL_free(buff);
- if (drbg != NULL) {
- RAND_DRBG_uninstantiate(drbg);
- RAND_DRBG_free(drbg);
- }
+ OPENSSL_free(buff);
+ RAND_DRBG_uninstantiate(drbg);
+ RAND_DRBG_free(drbg);
return failures == 0;
}
failures++;
err:
- if (buff != NULL)
- OPENSSL_free(buff);
- if (drbg != NULL) {
- RAND_DRBG_uninstantiate(drbg);
- RAND_DRBG_free(drbg);
- }
+ OPENSSL_free(buff);
+ RAND_DRBG_uninstantiate(drbg);
+ RAND_DRBG_free(drbg);
return failures == 0;
}
/*
- * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
} else if (strcmp(encoding, "invalid") == 0) {
edata->encoding = BASE64_INVALID_ENCODING;
if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
- return 0;
+ goto err;
} else {
TEST_error("Bad encoding: %s."
" Should be one of {canonical, valid, invalid}",
encoding);
- return 0;
+ goto err;
}
t->data = edata;
return 1;
+err:
+ OPENSSL_free(edata);
+ return 0;
}
static void encode_test_cleanup(EVP_TEST *t)
ENCODE_DATA *expected = t->data;
unsigned char *encode_out = NULL, *decode_out = NULL;
int output_len, chunk_len;
- EVP_ENCODE_CTX *decode_ctx;
+ EVP_ENCODE_CTX *decode_ctx = NULL, *encode_ctx = NULL;
if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
t->err = "INTERNAL_ERROR";
}
if (expected->encoding == BASE64_CANONICAL_ENCODING) {
- EVP_ENCODE_CTX *encode_ctx;
if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
|| !TEST_ptr(encode_out =
goto err;
EVP_EncodeInit(encode_ctx);
- EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
- expected->input, expected->input_len);
+ if (!TEST_true(EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
+ expected->input, expected->input_len)))
+ goto err;
+
output_len = chunk_len;
EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);
output_len += chunk_len;
- EVP_ENCODE_CTX_free(encode_ctx);
-
if (!memory_err_compare(t, "BAD_ENCODING",
expected->output, expected->output_len,
encode_out, output_len))
OPENSSL_free(encode_out);
OPENSSL_free(decode_out);
EVP_ENCODE_CTX_free(decode_ctx);
+ EVP_ENCODE_CTX_free(encode_ctx);
return 1;
}
/*
- * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
{
MEMPACKET_TEST_CTX *ctx = BIO_get_data(bio);
MEMPACKET *thispkt = NULL, *looppkt, *nextpkt, *allpkts[3];
- int i, duprec = ctx->duprec > 0;
+ int i, duprec;
const unsigned char *inu = (const unsigned char *)in;
size_t len = ((inu[RECORD_LEN_HI] << 8) | inu[RECORD_LEN_LO])
+ DTLS1_RT_HEADER_LENGTH;
if ((size_t)inl == len)
duprec = 0;
+ else
+ duprec = ctx->duprec > 0;
/* We don't support arbitrary injection when duplicating records */
if (duprec && pktnum != -1)