diff options
author | tb <> | 2021-12-28 20:58:05 +0000 |
---|---|---|
committer | tb <> | 2021-12-28 20:58:05 +0000 |
commit | d06fd3068d2b8bb4dc68ed93f43de63065b4a558 (patch) | |
tree | f94a4ed065de74e0bd2ad7f68ba5bee7384a9151 /src | |
parent | f3aa4f68c2f15c781d66ff3ee3b216eca30d8f43 (diff) | |
download | openbsd-d06fd3068d2b8bb4dc68ed93f43de63065b4a558.tar.gz openbsd-d06fd3068d2b8bb4dc68ed93f43de63065b4a558.tar.bz2 openbsd-d06fd3068d2b8bb4dc68ed93f43de63065b4a558.zip |
Validate AFIs before sorting in X509v3_adr_canonize()
Again, we're dealing with necessarily not fully validated data here,
so a check up front seems prudent.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/x509/x509_addr.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c index 3686d6a823..225f961002 100644 --- a/src/lib/libcrypto/x509/x509_addr.c +++ b/src/lib/libcrypto/x509/x509_addr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_addr.c,v 1.43 2021/12/28 20:50:37 tb Exp $ */ | 1 | /* $OpenBSD: x509_addr.c,v 1.44 2021/12/28 20:58:05 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Contributed to the OpenSSL Project by the American Registry for | 3 | * Contributed to the OpenSSL Project by the American Registry for |
4 | * Internet Numbers ("ARIN"). | 4 | * Internet Numbers ("ARIN"). |
@@ -1274,10 +1274,16 @@ IPAddressOrRanges_canonize(IPAddressOrRanges *aors, const unsigned afi) | |||
1274 | int | 1274 | int |
1275 | X509v3_addr_canonize(IPAddrBlocks *addr) | 1275 | X509v3_addr_canonize(IPAddrBlocks *addr) |
1276 | { | 1276 | { |
1277 | unsigned int afi; | ||
1277 | int i; | 1278 | int i; |
1278 | 1279 | ||
1279 | for (i = 0; i < sk_IPAddressFamily_num(addr); i++) { | 1280 | for (i = 0; i < sk_IPAddressFamily_num(addr); i++) { |
1280 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); | 1281 | IPAddressFamily *f = sk_IPAddressFamily_value(addr, i); |
1282 | |||
1283 | /* Check AFI/SAFI here - IPAddressFamily_cmp() can't error. */ | ||
1284 | if ((afi = X509v3_addr_get_afi(f)) == 0) | ||
1285 | return 0; | ||
1286 | |||
1281 | if (f->ipAddressChoice->type == | 1287 | if (f->ipAddressChoice->type == |
1282 | IPAddressChoice_addressesOrRanges && | 1288 | IPAddressChoice_addressesOrRanges && |
1283 | !IPAddressOrRanges_canonize(f->ipAddressChoice->u.addressesOrRanges, | 1289 | !IPAddressOrRanges_canonize(f->ipAddressChoice->u.addressesOrRanges, |