This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] cygcheck: Use snprintf instead of multiple strcat
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 23 Oct 2016 14:45:47 -0000
- Subject: [newlib-cygwin] cygcheck: Use snprintf instead of multiple strcat
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9807a501b16cda8cf95042cde2a7d76eb7d3b9e1
commit 9807a501b16cda8cf95042cde2a7d76eb7d3b9e1
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sun Oct 23 16:16:22 2016 +0200
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>
Diff:
---
winsup/utils/cygcheck.cc | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc
index 59d4735..d1e27b7 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)