[dpdk-stable] [PATCH v2] lib/cfgfile: replace strcat with strlcat
Chaitanya Babu Talluri
tallurix.chaitanya.babu at intel.com
Fri Mar 8 13:45:50 CET 2019
Replace strcat with strlcat to avoid buffer overflow.
Fixes: a6a47ac9c2 ("cfgfile: rework load function")
Cc: stable at dpdk.org
Signed-off-by: Chaitanya Babu Talluri <tallurix.chaitanya.babu at intel.com>
---
v2: Instead of strcat, used strlcat.
---
lib/librte_cfgfile/rte_cfgfile.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 7d8c941ea..3296bb6f8 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -8,6 +8,7 @@
#include <ctype.h>
#include <errno.h>
#include <rte_common.h>
+#include <rte_string_fns.h>
#include "rte_cfgfile.h"
@@ -224,10 +225,11 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
_strip(split[1], strlen(split[1]));
char *end = memchr(split[1], '\\', strlen(split[1]));
+ size_t split_len = strlen(split[1]) + 1;
while (end != NULL) {
if (*(end+1) == params->comment_character) {
*end = '\0';
- strcat(split[1], end+1);
+ strlcat(split[1], end+1, split_len);
} else
end++;
end = memchr(end, '\\', strlen(end));
--
2.17.2
More information about the stable
mailing list