Avoid signed integer overflow by casting an int64_t to uint64_t before
negating. Same fix was applied in a_int.c -r1.44, but was forgotten to
be applied to a_enum.c.
ok jsing
-/* $OpenBSD: a_enum.c,v 1.25 2022/07/09 14:46:43 tb Exp $ */
+/* $OpenBSD: a_enum.c,v 1.26 2022/08/10 12:06:28 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
int
ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *aenum, int64_t val)
{
+ uint64_t uval;
+
asn1_aenum_clear(aenum);
+ uval = (uint64_t)val;
+
if (val < 0) {
aenum->type = V_ASN1_NEG_ENUMERATED;
- val = -val;
+ uval = -uval;
}
- return asn1_aint_set_uint64((uint64_t)val, &aenum->data, &aenum->length);
+ return asn1_aint_set_uint64(uval, &aenum->data, &aenum->length);
}
long