diff options
author | PW Hu <jlu.hpw@foxmail.com> | 2021-11-10 12:39:54 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-11-22 11:17:48 +0100 |
commit | 2349d7ba57c9327290df6f7bc18b7f0c3976ca9e (patch) | |
tree | 665b40724ec43bd912f90de936e06e4c890f9bdd /crypto | |
parent | 615a9b8798e6ec58f1b2e1ec08a0f6b3c8cb7f60 (diff) |
Fix the return check of OBJ_obj2txt
Also update OBJ_nid2obj.pod to document the possible return values.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17005)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cms/cms_dh.c | 2 | ||||
-rw-r--r-- | crypto/cms/cms_ec.c | 2 | ||||
-rw-r--r-- | crypto/cms/cms_sd.c | 4 | ||||
-rw-r--r-- | crypto/core_namemap.c | 2 | ||||
-rw-r--r-- | crypto/crmf/crmf_pbm.c | 4 | ||||
-rw-r--r-- | crypto/dh/dh_kdf.c | 2 |
6 files changed, 8 insertions, 8 deletions
diff --git a/crypto/cms/cms_dh.c b/crypto/cms/cms_dh.c index fe6289b205..f14546c703 100644 --- a/crypto/cms/cms_dh.c +++ b/crypto/cms/cms_dh.c @@ -118,7 +118,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri) if (kekctx == NULL) goto err; - if (!OBJ_obj2txt(name, sizeof(name), kekalg->algorithm, 0)) + if (OBJ_obj2txt(name, sizeof(name), kekalg->algorithm, 0) <= 0) goto err; kekcipher = EVP_CIPHER_fetch(pctx->libctx, name, pctx->propquery); diff --git a/crypto/cms/cms_ec.c b/crypto/cms/cms_ec.c index 65018956a8..b07af92bad 100644 --- a/crypto/cms/cms_ec.c +++ b/crypto/cms/cms_ec.c @@ -47,7 +47,7 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval, pctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", propq); if (pctx == NULL || EVP_PKEY_paramgen_init(pctx) <= 0) goto err; - if (!OBJ_obj2txt(groupname, sizeof(groupname), poid, 0) + if (OBJ_obj2txt(groupname, sizeof(groupname), poid, 0) <= 0 || !EVP_PKEY_CTX_set_group_name(pctx, groupname)) { ERR_raise(ERR_LIB_CMS, CMS_R_DECODE_ERROR); goto err; diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 4fbe09ca5f..34c021bba6 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -784,8 +784,8 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) const CMS_CTX *ctx = si->cms_ctx; char md_name[OSSL_MAX_NAME_SIZE]; - if (!OBJ_obj2txt(md_name, sizeof(md_name), - si->digestAlgorithm->algorithm, 0)) + if (OBJ_obj2txt(md_name, sizeof(md_name), + si->digestAlgorithm->algorithm, 0) <= 0) return 0; if (CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1) < 0) { diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index 415df3d839..e1da724bd2 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -397,7 +397,7 @@ static void get_legacy_evp_names(int base_nid, int nid, const char *pem_name, if ((obj = OBJ_nid2obj(nid)) != NULL) { char txtoid[OSSL_MAX_NAME_SIZE]; - if (OBJ_obj2txt(txtoid, sizeof(txtoid), obj, 1)) + if (OBJ_obj2txt(txtoid, sizeof(txtoid), obj, 1) > 0) num = ossl_namemap_add_name(arg, num, txtoid); } } diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c index aba6b3a16f..88a8480cf7 100644 --- a/crypto/crmf/crmf_pbm.c +++ b/crypto/crmf/crmf_pbm.c @@ -200,8 +200,8 @@ int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq, mac_nid = OBJ_obj2nid(pbmp->mac->algorithm); if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, mac_nid, NULL, &hmac_md_nid, NULL) - || !OBJ_obj2txt(hmac_mdname, sizeof(hmac_mdname), - OBJ_nid2obj(hmac_md_nid), 0)) { + || OBJ_obj2txt(hmac_mdname, sizeof(hmac_mdname), + OBJ_nid2obj(hmac_md_nid), 0) <= 0) { ERR_raise(ERR_LIB_CRMF, CRMF_R_UNSUPPORTED_ALGORITHM); goto err; } diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c index 7a234b8fb1..419e7711d3 100644 --- a/crypto/dh/dh_kdf.c +++ b/crypto/dh/dh_kdf.c @@ -70,7 +70,7 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen, const OSSL_PROVIDER *prov = EVP_MD_get0_provider(md); OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov); - if (!OBJ_obj2txt(key_alg, sizeof(key_alg), key_oid, 0)) + if (OBJ_obj2txt(key_alg, sizeof(key_alg), key_oid, 0) <= 0) return 0; return ossl_dh_kdf_X9_42_asn1(out, outlen, Z, Zlen, key_alg, |