Avoid signed integer overflow due to unary negation
authortb <tb@openbsd.org>
Wed, 10 Aug 2022 16:51:26 +0000 (16:51 +0000)
committertb <tb@openbsd.org>
Wed, 10 Aug 2022 16:51:26 +0000 (16:51 +0000)
commitfe0b96fe181cafaecd2fac193301da2ba5b7ad3b
treec7b294ad09b117272dbb4b418ec0a620956cbf30
parentc9c35ed080d7dfec5a148834806ea8a72349c269
Avoid signed integer overflow due to unary negation

The current X509_print_ex() tries too hard pretty printing negative
serialNumbers (which shouldn't occur in the first place). In particular,
negating LONG_MAX leads to signed overflow. Ditch the code dealing with
negative serialNumbers representable as long and fall back to the long
form printing. This simplifies the code and fixes

oss-fuzz #49944

with/ok jsing
lib/libcrypto/asn1/t_x509.c