DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] cryptodev: avoid algorithm strings null pointers
@ 2023-06-08  5:31 xixin.liu
  0 siblings, 0 replies; only message in thread
From: xixin.liu @ 2023-06-08  5:31 UTC (permalink / raw)
  To: dev; +Cc: gakhil, liuxixin2020

The crypto algorithm strings identifiers that are Continuous may be null,
so there is needed to add null judgment.
When testing with dpdk-test-crypto-perf and passing in the parameter
--auth-algo sm3-hmac, The program caused a segfault due to a null pointer
passed in by strcmp.
Adding this patch can solve the segfault problem.
---
 lib/cryptodev/rte_cryptodev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index a96114b2da..d325133319 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -346,6 +346,8 @@ rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
 	int ret = -1;	/* Invalid string */
 
 	for (i = 1; i < RTE_DIM(crypto_cipher_algorithm_strings); i++) {
+		if (crypto_cipher_algorithm_strings[i] == NULL)
+			continue;
 		if (strcmp(algo_string, crypto_cipher_algorithm_strings[i]) == 0) {
 			*algo_enum = (enum rte_crypto_cipher_algorithm) i;
 			ret = 0;
@@ -366,6 +368,8 @@ rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
 	int ret = -1;	/* Invalid string */
 
 	for (i = 1; i < RTE_DIM(crypto_auth_algorithm_strings); i++) {
+		if (crypto_auth_algorithm_strings[i] == NULL)
+			continue;
 		if (strcmp(algo_string, crypto_auth_algorithm_strings[i]) == 0) {
 			*algo_enum = (enum rte_crypto_auth_algorithm) i;
 			ret = 0;
@@ -386,6 +390,8 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
 	int ret = -1;	/* Invalid string */
 
 	for (i = 1; i < RTE_DIM(crypto_aead_algorithm_strings); i++) {
+		if (crypto_aead_algorithm_strings[i] == NULL)
+			continue;
 		if (strcmp(algo_string, crypto_aead_algorithm_strings[i]) == 0) {
 			*algo_enum = (enum rte_crypto_aead_algorithm) i;
 			ret = 0;
@@ -406,6 +412,8 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
 	int ret = -1;	/* Invalid string */
 
 	for (i = 1; i < RTE_DIM(crypto_asym_xform_strings); i++) {
+		if (crypto_asym_xform_strings[i] = NULL)
+			continue;
 		if (strcmp(xform_string,
 			crypto_asym_xform_strings[i]) == 0) {
 			*xform_enum = (enum rte_crypto_asym_xform_type) i;
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-08  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-08  5:31 [PATCH] cryptodev: avoid algorithm strings null pointers xixin.liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).