Skip to content

Commit 88e512c

Browse files
starseekercshorler
authored andcommitted
Use strncpy to copy path to buf
1 parent 09deafb commit 88e512c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/clutils/dirobj.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ std::string DirObj::Normalize( const std::string & path ) {
257257
const char * DirObj::ValidDirectories( const char * path ) {
258258
#ifdef _WIN32
259259
static char buf[MAX_PATH + 1];
260+
strncpy(buf, path, MAX_PATH);
260261
#else
261262
static char buf[MAXPATHLEN + 1];
263+
strncpy(buf, path, MAXPATHLEN);
262264
#endif
263-
strcpy( buf, path );
264265
int i = strlen( path );
265266

266267
while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) {

0 commit comments

Comments
 (0)