}\r
fclose(f);\r
barbaric = (j != 0);\r
- strcpy(oldLanguage, buf);\r
+ safeStrCpy(oldLanguage, buf, sizeof(oldLanguage)/sizeof(oldLanguage[0]) );\r
}\r
\r
char *\r
for(j=GetMenuItemCount(subMenu)-1; j>=0; j--){\r
char buf[MSG_SIZ];\r
UINT k = GetMenuItemID(subMenu, j);\r
- if(menuText[i][j]) strcpy(buf, menuText[i][j]); else {\r
+ if(menuText[i][j])
+ safeStrCpy(buf, menuText[i][j], sizeof(buf)/sizeof(buf[0]) ); else {\r
GetMenuString(subMenu, j, buf, MSG_SIZ, MF_BYPOSITION);\r
menuText[i][j] = strdup(buf); // remember original on first change\r
}\r
if(strcmp(curName, oldUserName)) {\r
sprintf(oldUserName, "logos\\%s.bmp", curName);\r
userLogo = LoadImage( 0, oldUserName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); \r
- strcpy(oldUserName, curName);\r
+ safeStrCpy(oldUserName, curName, sizeof(oldUserName)/sizeof(oldUserName[0]) );\r
}\r
}\r
}\r
ShowWindow(hwndConsole, nCmdShow);\r
if(appData.chatBoxes) { // [HGM] chat: open chat boxes\r
char buf[MSG_SIZ], *p = buf, *q;\r
- strcpy(buf, appData.chatBoxes);\r
+ safeStrCpy(buf, appData.chatBoxes, sizeof(buf)/sizeof(buf[0]) );\r
do {\r
q = strchr(p, ';');\r
if(q) *q++ = 0;\r
lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;\r
lf->lfQuality = DEFAULT_QUALITY;\r
lf->lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;\r
- strcpy(lf->lfFaceName, mfp->faceName);\r
+ safeStrCpy(lf->lfFaceName, mfp->faceName, sizeof(lf->lfFaceName)/sizeof(lf->lfFaceName[0]) );\r
}\r
\r
void\r
if(name[0]== '%') {\r
fullname[0] = 0; // [HGM] first expand any environment variables in the given name\r
while(*p == '%' && (q = strchr(p+1, '%'))) { // [HGM] recognize %*% as environment variable\r
- strcpy(buf, p+1);\r
+ safeStrCpy(buf, p+1, sizeof(buf)/sizeof(buf[0]) );\r
*strchr(buf, '%') = 0;\r
strcat(fullname, getenv(buf));\r
p = q+1; while(*p == '\\') { strcat(fullname, "\\"); p++; }\r
if (gameInfo.event &&\r
strcmp(gameInfo.event, "Easter Egg Hunt") == 0 &&\r
strcmp(name, "k80s") == 0) {\r
- strcpy(name, "tim");\r
+ safeStrCpy(name, "tim", sizeof(name)/sizeof(name[0]) );\r
}\r
return LoadBitmap(hinst, name);\r
}\r
\r
cfmt.cbSize = sizeof(CHARFORMAT);\r
cfmt.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET;\r
- strcpy(cfmt.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);\r
+ safeStrCpy(cfmt.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName,\r
+ sizeof(cfmt.szFaceName)/sizeof(cfmt.szFaceName[0]) );\r
/* yHeight is expressed in twips. A twip is 1/20 of a font's point\r
* size. This was undocumented in the version of MSVC++ that I had\r
* when I wrote the code, but is apparently documented now.\r
\r
if (fileName == NULL) fileName = buf1;\r
if (defName == NULL) {\r
- strcpy(fileName, "*.");\r
+ safeStrCpy(fileName, "*.", sizeof(fileName)/sizeof(fileName[0]) );\r
strcat(fileName, defExt);\r
} else {\r
- strcpy(fileName, defName);\r
+ safeStrCpy(fileName, defName, sizeof(fileName)/sizeof(fileName[0]) );\r
}\r
- if (fileTitle) strcpy(fileTitle, "");\r
+ if (fileTitle) safeStrCpy(fileTitle, "", sizeof(fileTitle)/sizeof(fileTitle[0]) );\r
if (number) *number = 0;\r
\r
openFileName.lStructSize = sizeof(OPENFILENAME);\r
switch (LOWORD(wParam)) {\r
case IDOK:\r
if (IsDlgButtonChecked(hDlg, OPT_ChessEngine)) {\r
- strcpy(buf, "/fcp=");\r
+ safeStrCpy(buf, "/fcp=", sizeof(buf)/sizeof(buf[0]) );\r
GetDlgItemText(hDlg, OPT_ChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
p = buf;\r
ParseArgs(StringGet, &p);\r
- strcpy(buf, "/scp=");\r
+ safeStrCpy(buf, "/scp=", sizeof(buf)/sizeof(buf[0]) );\r
GetDlgItemText(hDlg, OPT_SecondChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
p = buf;\r
ParseArgs(StringGet, &p);\r
appData.noChessProgram = FALSE;\r
appData.icsActive = FALSE;\r
} else if (IsDlgButtonChecked(hDlg, OPT_ChessServer)) {\r
- strcpy(buf, "/ics /icshost=");\r
+ safeStrCpy(buf, "/ics /icshost=", sizeof(buf)/sizeof(buf[0]) );\r
GetDlgItemText(hDlg, OPT_ChessServerName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
p = buf;\r
ParseArgs(StringGet, &p);\r
if (appData.zippyPlay) {\r
- strcpy(buf, "/fcp=");\r
+ safeStrCpy(buf, "/fcp=", sizeof(buf)/sizeof(buf[0]) );\r
GetDlgItemText(hDlg, OPT_ChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf));\r
p = buf;\r
ParseArgs(StringGet, &p);\r
{\r
char title[MSG_SIZ], *host;\r
if (str[0] != NULLCHAR) {\r
- strcpy(title, str);\r
+ safeStrCpy(title, str, sizeof(title)/sizeof(title[0]) );\r
} else if (appData.icsActive) {\r
if (appData.icsCommPort[0] != NULLCHAR)\r
host = "ICS";\r
host = appData.icsHost;\r
sprintf(title, "%s: %s", szTitle, host);\r
} else if (appData.noChessProgram) {\r
- strcpy(title, szTitle);\r
+ safeStrCpy(title, szTitle, sizeof(title)/sizeof(title[0]) );\r
} else {\r
- strcpy(title, szTitle);\r
+ safeStrCpy(title, szTitle, sizeof(title)/sizeof(title[0]) );\r
strcat(title, ": ");\r
strcat(title, first.tidy);\r
}\r
int len;\r
\r
if (error == 0) {\r
- strcpy(buf, str);\r
+ safeStrCpy(buf, str, sizeof(buf)/sizeof(buf[0]) );\r
} else {\r
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,\r
NULL, error, LANG_NEUTRAL,\r
case WM_COMMAND:\r
switch (LOWORD(wParam)) {\r
case IDOK:\r
- strcpy(reply, qp->replyPrefix);\r
+ safeStrCpy(reply, qp->replyPrefix, sizeof(reply)/sizeof(reply[0]) );\r
if (*reply) strcat(reply, " ");\r
len = strlen(reply);\r
GetDlgItemText(hDlg, OPT_QuestionInput, reply + len, sizeof(reply) - len);\r
int result;\r
FARPROC lpProc = MakeProcInstance( (FARPROC) GameListOptions_Proc, hInst );\r
\r
- strcpy( lpUserGLT, appData.gameListTags );\r
+ safeStrCpy( lpUserGLT, appData.gameListTags ,LPUSERGLT_SIZE ); \r
\r
result = DialogBoxParam( hInst, MAKEINTRESOURCE(DLG_GameListOptions), hwndMain, (DLGPROC)lpProc, (LPARAM)lpUserGLT );\r
\r
}\r
if (!GetUserName(buf, &bufsiz)) {\r
/*DisplayError("Error getting user name", GetLastError());*/\r
- strcpy(buf, _("User"));\r
+ safeStrCpy(buf, _("User"), sizeof(buf)/sizeof(buf[0]) );\r
}\r
return buf;\r
}\r
\r
if (!GetComputerName(buf, &bufsiz)) {\r
/*DisplayError("Error getting host name", GetLastError());*/\r
- strcpy(buf, _("Unknown"));\r
+ safeStrCpy(buf, _("Unknown"), sizeof(buf)/sizeof(buf[0]) );\r
}\r
return buf;\r
}\r
if (*name != '\\')\r
sprintf(fullname, "\\\\.\\%s", name);\r
else\r
- strcpy(fullname, name);\r
+ safeStrCpy(fullname, name, sizeof(fullname)/sizeof(fullname[0]) );\r
\r
h = CreateFile(name, GENERIC_READ | GENERIC_WRITE,\r
0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);\r