asn1/a_int.c: clean up asn1_get_int64.
authorAndy Polyakov <appro@openssl.org>
Sat, 15 Apr 2017 13:53:50 +0000 (15:53 +0200)
committerAndy Polyakov <appro@openssl.org>
Mon, 17 Apr 2017 19:10:27 +0000 (21:10 +0200)
commit786b6a45fbecc068d0fb8b05252a9228e0661c63
tree80fca98d045718ac14b21e03648613390e405b61
parent5c8e9d531ba54d26e4bcbe66710c7c75bf0fc4e9
asn1/a_int.c: clean up asn1_get_int64.

Trouble was that integer negation wasn't producing *formally* correct
result in platform-neutral sense. Formally correct thing to do is
-(int64_t)u, but this triggers undefined behaviour for one value that
would still be representable in ASN.1. The trigger was masked with
(int64_t)(0-u), but this is formally inappropriate for values other
than the problematic one. [Also reorder branches to favour most-likely
paths and harmonize asn1_string_set_int64 with asn1_get_int64].]

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3231)
crypto/asn1/a_int.c