Skip to contentSkip to conversation

crypto: asymmetric_keys: Fix PKCS#7 selftest error reporting

PATCH In review m-amirpour 3 participants 3 messages Oct 17 – Nov 6

Subsystems (3)
lore
Share & tools
lore

m-amirpour

author
#0 lore raw

PATCH 1/1 crypto: asymmetric_keys: Fix PKCS#7 selftest error reporting

From: Muhammad Mahdi Amirpour <[email protected]>

pkcs7_parse_message() returns an error pointer on failure, but the selftest prints ret, which still contains the result of the previous x509_load_certificate_list() call.

Print the parser's error pointer with %pe so that a failure reports the actual parsing error.

---
 crypto/asymmetric_keys/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/asymmetric_keys/selftest.c +1 -1
index 98dc5cdfdeb..42857b02258 100644
@@ -41,7 +41,7 @@ void fips_signature_selftest(const char *name,
 
 	pkcs7 = pkcs7_parse_message(sig, sig_len);
 	if (IS_ERR(pkcs7))
-		panic("Certs %s selftest: pkcs7_parse_message() = %d\n", name, ret);
+		panic("Certs %s selftest: pkcs7_parse_message() = %pe\n", name, pkcs7);
 
 	pkcs7_supply_detached_data(pkcs7, data, data_len);
 
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · m-amirpour

From: Muhammad Mahdi Amirpour <[email protected]>

pkcs7_parse_message() returns an error pointer on failure, but the selftest prints ret, which still contains the result of the previous x509_load_certificate_list() call.

Print the parser's error pointer with %pe so that a failure reports the actual parsing error.

---
 crypto/asymmetric_keys/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/asymmetric_keys/selftest.c +0 -0
index 98dc5cdfdeb..42857b02258 100644

crypto/asymmetric_keys/selftest.c void fips_signature_selftest(const char *name, · line 46

Quoted 7 lines
crypto/asymmetric_keys/selftest.c +1 -1
@@ -41,7 +41,7 @@ void fips_signature_selftest(const char *name,
 
 	pkcs7 = pkcs7_parse_message(sig, sig_len);
 	if (IS_ERR(pkcs7))
-		panic("Certs %s selftest: pkcs7_parse_message() = %d\n", name, ret);
+		panic("Certs %s selftest: pkcs7_parse_message() = %pe\n", name, pkcs7);
 
 	pkcs7_supply_detached_data(pkcs7, data, data_len);

--Ben

maintainer
#2 lore raw
In reply to m-amirpour
Quoted 6 lines · m-amirpour

From: Muhammad Mahdi Amirpour <[email protected]>

pkcs7_parse_message() returns an error pointer on failure, but the selftest prints ret, which still contains the result of the previous x509_load_certificate_list() call.

Quoted 7 lines

Print the parser's error pointer with %pe so that a failure reports the actual parsing error.

---
 crypto/asymmetric_keys/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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