Linux Kernels

X.509: Fix error code in x509_cert_parse()

This change “X.509: Fix error code in x509_cert_parse()” (commit 3bca64c) in Linux kernel is authored by Dan Carpenter <dan.carpenter [at] oracle.com> on Mon May 29 16:26:22 2017 +0300.

Description of "X.509: Fix error code in x509_cert_parse()"

The change “X.509: Fix error code in x509_cert_parse()” introduces changes as follows.

X.509: Fix error code in x509_cert_parse()

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Linux kernel releases containing commit 3bca64c

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "X.509: Fix error code in x509_cert_parse()"

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 crypto/asymmetric_keys/x509_cert_parser.c | 1 +
 1 file changed, 1 insertion(+)
 
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..dd03fead1ca3 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 		}
 	}
 
+	ret = -ENOMEM;
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
 	if (!cert->pub->key)
 		goto error_decode;

The commit for this change in Linux stable tree is 3bca64c (patch).

Last modified: 2020/01/11 09:39