From: Tomasz Kulasek Date: Mon, 11 Apr 2016 16:03:48 +0000 (+0200) Subject: app/testpmd: fix string overrun in engines listing X-Git-Tag: spdx-start~6987 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=331c617bfb5e977c79099f6f833fdcd7f628349d;p=dpdk.git app/testpmd: fix string overrun in engines listing CID 13307 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW) fixed_size_dest: You might overrun the 128 byte fixed-size string fwd_modes by copying fwd_eng->fwd_mode_name without checking the length. Fixes: 769ce6b17835 ("app/testpmd: list forwarding engines") Signed-off-by: Tomasz Kulasek --- diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b1bbec6dc5..1c552e46a9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1673,8 +1673,10 @@ list_pkt_forwarding_modes(void) if (strlen (fwd_modes) == 0) { while ((fwd_eng = fwd_engines[i++]) != NULL) { - strcat(fwd_modes, fwd_eng->fwd_mode_name); - strcat(fwd_modes, separator); + strncat(fwd_modes, fwd_eng->fwd_mode_name, + sizeof(fwd_modes) - strlen(fwd_modes) - 1); + strncat(fwd_modes, separator, + sizeof(fwd_modes) - strlen(fwd_modes) - 1); } fwd_modes[strlen(fwd_modes) - strlen(separator)] = '\0'; }