[dpdk-dev,v2,1/2] app/crypto-perf: use strcpy for allocated string
diff mbox

Message ID 20180516122804.535-1-jerin.jacob@caviumnetworks.com
State Accepted, archived
Delegated to: Pablo de Lara Guarch
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jerin Jacob May 16, 2018, 12:28 p.m. UTC
inlined from ‘cperf_test_vector_get_from_file’ at
../app/test-crypto-perf/cperf_test_vector_parsing.c:578:11:
../app/test-crypto-perf/cperf_test_vector_parsing.c:510:3: error:
‘strncpy’ output truncated before terminating nul copying as many bytes
from a string as its length [-Werror=stringop-truncation]
   strncpy(entry, line, strlen(line));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../app/test-crypto-perf/cperf_test_vector_parsing.c:528:5: error:
‘strncat’ output truncated before terminating nul copying as many bytes
from a string as its length [-Werror=stringop-truncation]
     strncat(entry, line, strlen(line));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found this issue with meson build and gcc 8.1.

Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application")

Cc: declan.doherty@intel.com
Cc: andy@warmcat.com
Cc: stable@dpdk.org

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
v2: 
- No change
---
 app/test-crypto-perf/cperf_test_vector_parsing.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

De Lara Guarch, Pablo May 17, 2018, 4:31 p.m. UTC | #1
> -----Original Message-----

> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]

> Sent: Wednesday, May 16, 2018 1:28 PM

> To: dev@dpdk.org

> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;

> thomas@monjalon.net; Jerin Jacob <jerin.jacob@caviumnetworks.com>;

> Doherty, Declan <declan.doherty@intel.com>; andy@warmcat.com;

> stable@dpdk.org

> Subject: [dpdk-dev] [PATCH v2 1/2] app/crypto-perf: use strcpy for allocated

> string

> 

> inlined from ‘cperf_test_vector_get_from_file’ at

> ../app/test-crypto-perf/cperf_test_vector_parsing.c:578:11:

> ../app/test-crypto-perf/cperf_test_vector_parsing.c:510:3: error:

> ‘strncpy’ output truncated before terminating nul copying as many bytes from a

> string as its length [-Werror=stringop-truncation]

>    strncpy(entry, line, strlen(line));

>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> ../app/test-crypto-perf/cperf_test_vector_parsing.c:528:5: error:

> ‘strncat’ output truncated before terminating nul copying as many bytes from a

> string as its length [-Werror=stringop-truncation]

>      strncat(entry, line, strlen(line));

>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> Found this issue with meson build and gcc 8.1.

> 

> Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test

> application")

> 

> Cc: declan.doherty@intel.com

> Cc: andy@warmcat.com

> Cc: stable@dpdk.org

> 

> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>


Applied to dpdk-next-crypto.
Thanks,

Pablo

Patch
diff mbox

diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 26321d004..92932a230 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -506,8 +506,7 @@  parse_file(struct cperf_test_vector *vector, struct cperf_options *opts)
 		if (entry == NULL)
 			return -1;
 
-		memset(entry, 0, strlen(line) + 1);
-		strncpy(entry, line, strlen(line));
+		strcpy(entry, line);
 
 		/* check if entry ends with , or = */
 		if (entry[strlen(entry) - 1] == ','
@@ -524,8 +523,8 @@  parse_file(struct cperf_test_vector *vector, struct cperf_options *opts)
 				if (entry_extended == NULL)
 					goto err;
 				entry = entry_extended;
-
-				strncat(entry, line, strlen(line));
+				/* entry has been allocated accordingly */
+				strcpy(&entry[strlen(entry)], line);
 
 				if (entry[strlen(entry) - 1] != ',')
 					break;