[openssl-users] 1.1.1 pre1 tests failing on Solaris SPARC
Norm Green
norm.green at gemtalksystems.com
Tue Feb 20 16:36:55 UTC 2018
Hi Viktor,
Your patch tests clean, however there is an easier way which avoids malloc:
Norm
Index: test/asn1_encode_test.c
===================================================================
--- test/asn1_encode_test.c (revision 43654)
+++ test/asn1_encode_test.c (working copy)
@@ -706,15 +706,16 @@
return ret;
}
static int do_print_item(const TEST_PACKAGE *package)
{
#define DATA_BUF_SIZE 256
- unsigned char buf[DATA_BUF_SIZE];
+ uint64_t _buf[DATA_BUF_SIZE / sizeof(uint64_t)];/* force 8-byte
alignment */
+ unsigned char *buf = (unsigned char *) _buf;
const ASN1_ITEM *i = ASN1_ITEM_ptr(package->asn1_type);
- ASN1_VALUE *o = (ASN1_VALUE *)&buf;
+ ASN1_VALUE *o = (ASN1_VALUE *)buf;
int ret;
OPENSSL_assert(package->encode_expectations_elem_size <= DATA_BUF_SIZE);
(void)RAND_bytes(buf, (int)package->encode_expectations_elem_size);
ret = ASN1_item_print(bio_err, o, 0, i, NULL);
On 2/19/2018 9:00 PM, Viktor Dukhovni wrote:
> On Mon, Feb 19, 2018 at 01:45:26PM -0800, Norm Green wrote:
>
>> # ASN1_LONG_DATA:
>> # success: TRUE
>> t at 1 (l at 1) signal BUS (invalid address alignment) in asn1_item_print_ctx at
>> line 155 in file "tasn_prn.c"
>> 155 || (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) {
> Perhaps aligning the item buffer (by using malloc) will help, does
> the patch below address the problem?
>
> diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c
> index e9f459ad65..77fa9b5954 100644
> --- a/test/asn1_encode_test.c
> +++ b/test/asn1_encode_test.c
> @@ -709,15 +709,19 @@ static int do_encode_custom(EXPECTED *input,
> static int do_print_item(const TEST_PACKAGE *package)
> {
> #define DATA_BUF_SIZE 256
> - unsigned char buf[DATA_BUF_SIZE];
> const ASN1_ITEM *i = ASN1_ITEM_ptr(package->asn1_type);
> - ASN1_VALUE *o = (ASN1_VALUE *)&buf;
> + ASN1_VALUE *o = OPENSSL_malloc(DATA_BUF_SIZE);
> int ret;
>
> OPENSSL_assert(package->encode_expectations_elem_size <= DATA_BUF_SIZE);
>
> - (void)RAND_bytes(buf, (int)package->encode_expectations_elem_size);
> + if (o == NULL)
> + return 0;
> +
> + (void)RAND_bytes((unsigned char *)o,
> + (int)package->encode_expectations_elem_size);
> ret = ASN1_item_print(bio_err, o, 0, i, NULL);
> + OPENSSL_free(o);
>
> return ret;
> }
>
More information about the openssl-users
mailing list