diff options
| author | tb <> | 2021-12-28 15:59:13 +0000 |
|---|---|---|
| committer | tb <> | 2021-12-28 15:59:13 +0000 |
| commit | 4cb6e8841ebb2057eb6551992c46f0a401569801 (patch) | |
| tree | bfdc765c3802af50aa51ec0046deaae839512b03 | |
| parent | 5491024cb5cfc8b5ad8ead3147278f4272d612f9 (diff) | |
| download | openbsd-4cb6e8841ebb2057eb6551992c46f0a401569801.tar.gz openbsd-4cb6e8841ebb2057eb6551992c46f0a401569801.tar.bz2 openbsd-4cb6e8841ebb2057eb6551992c46f0a401569801.zip | |
Check for trailing garbage in X509_addr_get_afi()
Per RFC 3779 2.2.3.3, the addressFamily field contains the 2-byte AFI
and an optional 1-byte SAFI. Nothing else. The optional SAFI is nowhere
exposed in the API. It is used expliclty only for pretty printing. There
are implicit uses in a few places, notably for sorting/comparing where
trailing garbage would be erroneously taken into account.
Erroring in this situation will let us avoid this in upcoming revisions.
ok inoguchi jsing
| -rw-r--r-- | src/lib/libcrypto/x509/x509_addr.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/x509/x509_addr.c b/src/lib/libcrypto/x509/x509_addr.c index 64dd830514..fda73b304e 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.29 2021/12/28 15:49:11 tb Exp $ */ | 1 | /* $OpenBSD: x509_addr.c,v 1.30 2021/12/28 15:59:13 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"). |
| @@ -354,6 +354,10 @@ X509v3_addr_get_afi(const IPAddressFamily *f) | |||
| 354 | if (!CBS_get_u16(&cbs, &afi)) | 354 | if (!CBS_get_u16(&cbs, &afi)) |
| 355 | return 0; | 355 | return 0; |
| 356 | 356 | ||
| 357 | /* One byte for the optional SAFI, everything else is garbage. */ | ||
| 358 | if (CBS_len(&cbs) > 1) | ||
| 359 | return 0; | ||
| 360 | |||
| 357 | return afi; | 361 | return afi; |
| 358 | } | 362 | } |
| 359 | 363 | ||
