From 9ae9a63403f24a188ce29f18f6495aeb51bc584f Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Tue, 14 Apr 2020 11:56:07 +0000
Subject: [PATCH] Only copy up to MAX_PATH characters to each component in
 _splitpath() Fixes coverity warning in SyncTERM... matches the size all
 callers currently use.

---
 src/xpdev/dirwrap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index 7ae18e1d61..f03b70e8fd 100644
--- a/src/xpdev/dirwrap.c
+++ b/src/xpdev/dirwrap.c
@@ -152,16 +152,16 @@ void DLLCALL _splitpath(const char *path, char *drive, char *dir, char *fname, c
 	ext[0]=0;
 	drive[0]=0;			/* no drive letters on Unix */
 
-	strcpy(dir,path);	/* Optional directory path, including trailing slash. */
+	snprintf(dir, MAX_PATH+1, "%s", path);	/* Optional directory path, including trailing slash. */
 	p=getfname(dir);
-	strcpy(fname,p);	/* Base filename (no extension) */
+	snprintf(fname, MAX_PATH+1, "%s", p);	/* Base filename (no extension) */
 	if(p==dir)
 		dir[0]=0;		/* no directory specified in path */
 	else
 		*p=0;			/* truncate dir at filename */
 	p=getfext(fname);
 	if(p!=NULL) {
-		strcpy(ext,p);	/* Optional filename extension, including leading period (.) */
+		snprintf(ext, MAX_PATH+1, "%s", p);	/* Optional filename extension, including leading period (.) */
 		*p=0;
 	}
 }
-- 
GitLab