Cast to an unsigned type before negating
authorKurt Roeckx <kurt@roeckx.be>
Fri, 11 Nov 2016 20:41:50 +0000 (21:41 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Sat, 12 Nov 2016 13:09:20 +0000 (14:09 +0100)
commitfadfc8ecfd277af189600648fcf1d28f33fd76fe
treef807bf35ba6208fc8b6145b25b4b4cd81190087d
parent0f251d20a5c40cb9b6d30dfec005bb4ead3d5b0f
Cast to an unsigned type before negating

llvm's ubsan reported:
runtime error: negation of -9223372036854775808 cannot be represented in
type 'int64_t' (aka 'long'); cast to an unsigned type to negate this
value to itself

Found using libfuzzer

Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1908
(cherry picked from commit e80f3b6af295133107ac709329eee16ccf9af61c)
crypto/asn1/a_int.c