summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-10-23 16:16:22 +0200
committerCorinna Vinschen <corinna@vinschen.de>2016-10-23 16:16:22 +0200
commit9807a501b16cda8cf95042cde2a7d76eb7d3b9e1 (patch)
tree36c698ac0d8e67e995d52afe7b251ba9ffcdef6d
parentf16f20ff959eb02c05f32b609d3f4fa193233d0a (diff)
downloadcygnal-9807a501b16cda8cf95042cde2a7d76eb7d3b9e1.tar.gz
cygnal-9807a501b16cda8cf95042cde2a7d76eb7d3b9e1.tar.bz2
cygnal-9807a501b16cda8cf95042cde2a7d76eb7d3b9e1.zip
cygcheck: Use snprintf instead of multiple strcat
This not only simplifies the code but also fixes potential memory corruption Fixes Coverity CID 66952 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/utils/cygcheck.cc5
1 files changed, 1 insertions, 4 deletions
diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc
index 59d473530..d1e27b7e9 100644
--- a/winsup/utils/cygcheck.cc
+++ b/winsup/utils/cygcheck.cc
@@ -311,10 +311,7 @@ pathlike::check_existence (const char *fn, int showall, int verbose,
char* first, const char *ext1, const char *ext2)
{
char file[4000];
- strcpy (file, dir);
- strcat (file, fn);
- strcat (file, ext1);
- strcat (file, ext2);
+ snprintf (file, sizeof file, "%s%s%s%s", dir, fn, ext1, ext2);
wide_path wpath (file);
if (GetFileAttributesW (wpath) != (DWORD) - 1)