X.509: Fix error code in x509_cert_parse()
Subsystems (4)
PATCH 1/1 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.
crypto/asymmetric_keys/x509_cert_parser.c +3 -1
@@ -103,8 +103,10 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen) } cert->pub->key =kmemdup (ctx->key, ctx->key_size,GFP_KERNEL ); -if (!cert->pub->key) +if (!cert->pub->key) { + ret = -ENOMEM ; goto error_decode; + } cert->pub->keylen = ctx->key_size;
David Howells
maintainercrypto/asymmetric_keys/x509_cert_parser.c struct x509_certificate *x509_cert_parse(const void *data, size_t datalen) · line 109
Quoted 6 lines · Dan Carpenter
crypto/asymmetric_keys/x509_cert_parser.c +3
-1cert->pub->key =kmemdup (ctx->key, ctx->key_size,GFP_KERNEL ); -if (!cert->pub->key) +if (!cert->pub->key) { + ret = -ENOMEM ; goto error_decode; + }
Put the "ret = -ENOMEM" line before the kmemdup line maybe?
David
PATCH v2 1/1 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.
---
v2: Style change
Sorry for the delay, I'm been out of office.
crypto/asymmetric_keys/x509_cert_parser.c +1 -0
@@ -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;
Herbert Xu
maintainerQuoted 7 lines · Dan Carpenter
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 <[email protected]>---
v2: Style change
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
David Howells
maintainerQuoted 1 line · Herbert Xu
Patch applied. Thanks.
Note that I've passed this on to James to pass on to Linus along with a bunch of other patches.
David