patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v1] test/crypto: fix comparison function for modex values
@ 2024-07-15 13:38 Gowrishankar Muthukrishnan
  2024-07-16  6:06 ` Anoob Joseph
  0 siblings, 1 reply; 3+ messages in thread
From: Gowrishankar Muthukrishnan @ 2024-07-15 13:38 UTC (permalink / raw)
  To: dev, Akhil Goyal, Fan Zhang, Gowrishankar Muthukrishnan
  Cc: Anoob Joseph, stable

Fix comparison function used by modex test to check from
first non-zero value itself.

Coverity issue: 430125
Fixes: 2162d32c1c3 ("test/crypto: validate modex from first non-zero")
Cc: stable@dpdk.org

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_cryptodev_asym.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 1d88832146..f0b5d38543 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -3197,21 +3197,26 @@ static int send_one(void)
 }
 
 static int
-modular_cmpeq(const uint8_t *a, const uint8_t *b, size_t len)
+modular_cmpeq(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len)
 {
-	const uint8_t *new_a = a, *new_b = b;
+	const uint8_t *new_a, *new_b;
 	size_t i, j;
 
 	/* Strip leading NUL bytes */
-	for (i = 0; i < len; i++)
+	for (i = 0; i < a_len; i++)
 		if (a[i] != 0)
-			new_a = &a[i];
+			break;
 
-	for (j = 0; j < len; j++)
+	for (j = 0; j < b_len; j++)
 		if (b[j] != 0)
-			new_b = &b[i];
+			break;
+
+	if (a_len - i != b_len - j)
+		return 1;
 
-	if (i != j || memcmp(new_a, new_b, len - i))
+	new_a = &a[i];
+	new_b = &b[j];
+	if (memcmp(new_a, new_b, a_len - i))
 		return 1;
 
 	return 0;
@@ -3251,7 +3256,7 @@ modular_exponentiation(const void *test_data)
 
 	TEST_ASSERT_SUCCESS(send_one(),
 		"Failed to process crypto op");
-	TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data,
+	TEST_ASSERT_SUCCESS(modular_cmpeq(vector->reminder.data, vector->reminder.len,
 			self->result_op->asym->modex.result.data,
 			self->result_op->asym->modex.result.length),
 			"operation verification failed\n");
-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1] test/crypto: fix comparison function for modex values
  2024-07-15 13:38 [PATCH v1] test/crypto: fix comparison function for modex values Gowrishankar Muthukrishnan
@ 2024-07-16  6:06 ` Anoob Joseph
  2024-07-19 13:03   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Anoob Joseph @ 2024-07-16  6:06 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev, Akhil Goyal, Fan Zhang,
	Gowrishankar Muthukrishnan
  Cc: stable

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

> Subject: [PATCH v1] test/crypto: fix comparison function for modex values
> 
> Fix comparison function used by modex test to check from first non-zero value
> itself.
> 
> Coverity issue: 430125
> Fixes: 2162d32c1c3 ("test/crypto: validate modex from first non-zero")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Acked-by: Anoob Joseph <anoobj@marvell.com>



[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14621 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1] test/crypto: fix comparison function for modex values
  2024-07-16  6:06 ` Anoob Joseph
@ 2024-07-19 13:03   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2024-07-19 13:03 UTC (permalink / raw)
  To: Anoob Joseph, Gowrishankar Muthukrishnan, dev, Fan Zhang,
	Gowrishankar Muthukrishnan
  Cc: stable

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]

> Subject: RE: [PATCH v1] test/crypto: fix comparison function for modex values
> 
> > Subject: [PATCH v1] test/crypto: fix comparison function for modex values
> >
> > Fix comparison function used by modex test to check from first non-zero value
> > itself.
> >
> > Coverity issue: 430125
> > Fixes: 2162d32c1c3 ("test/crypto: validate modex from first non-zero")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> 
> Acked-by: Anoob Joseph <anoobj@marvell.com>
> 
Applied to dpdk-next-crypto

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14897 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-19 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-15 13:38 [PATCH v1] test/crypto: fix comparison function for modex values Gowrishankar Muthukrishnan
2024-07-16  6:06 ` Anoob Joseph
2024-07-19 13:03   ` Akhil Goyal

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).