summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2016-04-07 14:23:09 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-04-07 19:52:07 +0200
commit99218e76fec87681053ea207ae2ae2253827c56a (patch)
tree3092052478e19c189cc6dc0f4c39b36403150a7a /examples
parent2c007ea106161917270ed14a21471de5cc38ab0c (diff)
downloaddpdk-99218e76fec87681053ea207ae2ae2253827c56a.zip
dpdk-99218e76fec87681053ea207ae2ae2253827c56a.tar.gz
dpdk-99218e76fec87681053ea207ae2ae2253827c56a.tar.xz
examples/l2fwd-crypto: fix string overflow
When parsing crypto device type, the string was being copied with strcpy(), which could overflow the destination buffer (which is 32 byte long), so snprintf() should be used instead. This fixes coverity issue 124575: /examples/l2fwd-crypto/main.c: 1005 in l2fwd_crypto_parse_args_long_options() >>> CID 124575: (STRING_OVERFLOW) >>> You might overrun the 32 byte fixed-size string "options->string_auth_algo" by copying "optarg" without checking the length. 1005 strcpy(options->string_auth_algo, optarg); Fixes: 49f79e86480d ("examples/l2fwd-crypto: add missing string initialization") Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/l2fwd-crypto/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 182dc56..d4e2d8d 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -1012,7 +1012,8 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
if (strcmp(lgopts[option_index].name, "cdev_type") == 0) {
retval = parse_cryptodev_type(&options->type, optarg);
if (retval == 0)
- strcpy(options->string_type, optarg);
+ snprintf(options->string_type, MAX_STR_LEN,
+ "%s", optarg);
return retval;
}