diff options
| author | jsing <> | 2022-06-28 19:44:28 +0000 |
|---|---|---|
| committer | jsing <> | 2022-06-28 19:44:28 +0000 |
| commit | 4edad9b6e581e10291c227e2c7fb1f3a7a686cde (patch) | |
| tree | 49119ef2899ea30bdf9890fb1dd0fd5ae2e274be /src | |
| parent | 6a00fddbb48bbfc1b0cd39ce431d282916f3be00 (diff) | |
| download | openbsd-4edad9b6e581e10291c227e2c7fb1f3a7a686cde.tar.gz openbsd-4edad9b6e581e10291c227e2c7fb1f3a7a686cde.tar.bz2 openbsd-4edad9b6e581e10291c227e2c7fb1f3a7a686cde.zip | |
Negate unsigned then cast to signed.
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@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_int.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 546713ae46..38a2e1cfa5 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_int.c,v 1.41 2022/06/25 15:39:12 jsing Exp $ */ | 1 | /* $OpenBSD: a_int.c,v 1.42 2022/06/28 19:44:28 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -207,7 +207,7 @@ asn1_aint_get_int64(CBS *cbs, int negative, int64_t *out_val) | |||
| 207 | ASN1error(ASN1_R_TOO_SMALL); | 207 | ASN1error(ASN1_R_TOO_SMALL); |
| 208 | return 0; | 208 | return 0; |
| 209 | } | 209 | } |
| 210 | *out_val = -(int64_t)val; | 210 | *out_val = (int64_t)-val; |
| 211 | } else { | 211 | } else { |
| 212 | if (val > (uint64_t)INT64_MAX) { | 212 | if (val > (uint64_t)INT64_MAX) { |
| 213 | ASN1error(ASN1_R_TOO_LARGE); | 213 | ASN1error(ASN1_R_TOO_LARGE); |
