From e0137ca92b4abf65acde15b255ae58d7e76af22f Mon Sep 17 00:00:00 2001 From: Nicola Tuveri Date: Mon, 29 Jun 2020 00:53:46 +0300 Subject: [EC][ASN1] Detect missing OID when serializing EC parameters and keys The following built-in curves do not have an assigned OID: - Oakley-EC2N-3 - Oakley-EC2N-4 In general we shouldn't assume that an OID is always available. This commit detects such cases, raises an error and returns appropriate return values so that the condition can be detected and correctly handled by the callers, when serializing EC parameters or EC keys with the default `ec_param_enc:named_curve`. Fixes #12306 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12313) --- crypto/pem/pem_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crypto/pem') diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index c170f60bcd..bd20bbb783 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -334,7 +334,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, } } - if ((dsize = i2d(x, NULL)) < 0) { + if ((dsize = i2d(x, NULL)) <= 0) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, ERR_R_ASN1_LIB); dsize = 0; goto err; -- cgit v1.2.3