@@ -115,11 +115,10 @@ void OpenMap::populateMapListbox( Bool systemMaps )
115115 char fileBuf[_MAX_PATH];
116116
117117 if (systemMaps)
118- strcpy (dirBuf, " Maps\\ " );
118+ strlcpy (dirBuf, " Maps\\ " , ARRAY_SIZE (dirBuf) );
119119 else
120120 {
121- strcpy (dirBuf, TheGlobalData->getPath_UserData ().str ());
122- strlcat (dirBuf, " Maps\\ " , ARRAY_SIZE (dirBuf));
121+ snprintf (dirBuf, ARRAY_SIZE (dirBuf), " %sMaps\\ " , TheGlobalData->getPath_UserData ().str ());
123122 }
124123
125124 int len = strlen (dirBuf);
@@ -131,8 +130,7 @@ void OpenMap::populateMapListbox( Bool systemMaps )
131130 CListBox *pList = (CListBox *)this ->GetDlgItem (IDC_OPEN_LIST);
132131 if (pList == NULL ) return ;
133132 pList->ResetContent ();
134- strcpy (findBuf, dirBuf);
135- strlcat (findBuf, " *.*" , ARRAY_SIZE (findBuf));
133+ snprintf (findBuf, ARRAY_SIZE (findBuf), " %s*.*" , dirBuf);
136134
137135 Bool found = false ;
138136
@@ -141,15 +139,11 @@ void OpenMap::populateMapListbox( Bool systemMaps )
141139 do {
142140 if (strcmp (findData.cFileName , " ." ) == 0 || strcmp (findData.cFileName , " .." ) == 0 )
143141 continue ;
144- if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) {
145- continue ;
146- }
142+ if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) {
143+ continue ;
144+ }
147145
148- strcpy (fileBuf, dirBuf);
149- strlcat (fileBuf, findData.cFileName , ARRAY_SIZE (findBuf));
150- strlcat (fileBuf, " \\ " , ARRAY_SIZE (findBuf));
151- strlcat (fileBuf, findData.cFileName , ARRAY_SIZE (findBuf));
152- strlcat (fileBuf, " .map" , ARRAY_SIZE (findBuf));
146+ snprintf (fileBuf, ARRAY_SIZE (fileBuf), " %s%s\\ %s.map" , dirBuf, findData.cFileName , findData.cFileName );
153147 try {
154148 CFileStatus status;
155149 if (CFile::GetStatus (fileBuf, status)) {
0 commit comments