Add check for the return value of gnutls_malloc() to avoid potential NULL pointer dereference.
Fixes: be560a813 ("Added gnutls_pkcs11_privkey_t and gnutls_privkey_t types. Those are an abstract private key type that can be used to sign/encrypt any private key of pkcs11,x509 or openpgp types. Added support for PKCS11 in gnutls-cli/gnutls-serv.")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
}
tmp.data = gnutls_malloc(siglen);
+ if (tmp.data == NULL) {
+ gnutls_assert();
+ ret = GNUTLS_E_MEMORY_ERROR;
+ goto cleanup;
+ }
+
tmp.size = siglen;
rv = pkcs11_sign(sinfo->module, sinfo->pks, hash->data, hash->size,
}
plaintext->data = gnutls_malloc(siglen);
+ if (plaintext->data == NULL) {
+ gnutls_assert();
+ ret = GNUTLS_E_MEMORY_ERROR;
+ goto cleanup;
+ }
+
plaintext->size = siglen;
rv = pkcs11_decrypt(key->sinfo.module, key->sinfo.pks, ciphertext->data,