Avoid undefined behaviour by negating the unsigned value, before casting
to int64_t, rather than casting to int64_t then negating.
Fixes oss-fuzz #48499
ok tb@
-/* $OpenBSD: a_int.c,v 1.41 2022/06/25 15:39:12 jsing Exp $ */
+/* $OpenBSD: a_int.c,v 1.42 2022/06/28 19:44:28 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
ASN1error(ASN1_R_TOO_SMALL);
return 0;
}
- *out_val = -(int64_t)val;
+ *out_val = (int64_t)-val;
} else {
if (val > (uint64_t)INT64_MAX) {
ASN1error(ASN1_R_TOO_LARGE);