浏览代码

Coverity: fix 1506297: negative returns

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18587)
Pauli 1 年之前
父节点
当前提交
3ee2611677
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      crypto/dsa/dsa_ameth.c

+ 5 - 0
crypto/dsa/dsa_ameth.c

@@ -198,6 +198,11 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
 
     ASN1_STRING_clear_free(prkey);
 
+    if (dplen <= 0) {
+        ERR_raise(ERR_LIB_DSA, DSA_R_BN_ERROR);
+        goto err;
+    }
+
     if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0,
                          V_ASN1_SEQUENCE, params, dp, dplen)) {
         OPENSSL_clear_free(dp, dplen);