security fix: replaced strcpy with safeStrCpy from backend.c
[xboard.git] / winboard / wsettings.c
index fc0dc12..a250e2e 100644 (file)
 #include <stdio.h>\r
 #include <string.h>\r
 #include "common.h"\r
+#include "frontend.h"\r
 #include "backend.h"\r
+#include "winboard.h"\r
 #include "backendz.h"\r
 \r
+#define _(s) T_(s)\r
+\r
 int layoutList[2*MAX_OPTIONS];\r
 int checkList[2*MAX_OPTIONS];\r
 int comboList[2*MAX_OPTIONS];\r
@@ -275,9 +279,9 @@ SetOptionValues(HWND hDlg, ChessProgramState *cps)
                break;\r
        }\r
     }\r
-    SetDlgItemText( hDlg, IDOK, "OK" );\r
-    SetDlgItemText( hDlg, IDCANCEL, "Cancel" );\r
-    sprintf(title, "%s Engine Settings (%s)", cps->which, cps->tidy); \r
+    SetDlgItemText( hDlg, IDOK, _("OK") );\r
+    SetDlgItemText( hDlg, IDCANCEL, _("Cancel") );\r
+    sprintf(title, _("%s Engine Settings (%s)"), T_(cps->which), cps->tidy); \r
     title[0] &= ~32; // capitalize\r
     SetWindowText( hDlg, title);\r
     for(i=0; i<groups; i+=2) { \r
@@ -319,7 +323,7 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps)
                success = GetDlgItemText( hDlg, 2001+2*i, newText, MSG_SIZ - strlen(cps->option[j].name) - 9 );\r
                if(!success) break;\r
                changed = strcmp(cps->option[j].textValue, newText) != 0;\r
-               strcpy(cps->option[j].textValue, newText);\r
+               safeStrCpy(cps->option[j].textValue, newText, sizeof(cps->option[j].textValue)/sizeof(cps->option[j].textValue[0]) );\r
                break;\r
            case CheckBox:\r
                new = IsDlgButtonChecked( hDlg, 2000+2*i );\r
@@ -393,7 +397,7 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
 */\r
                          OPENFILENAME ofn;\r
 \r
-                         strcpy( buf, "" );\r
+                         safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) );\r
 \r
                          ZeroMemory( &ofn, sizeof(ofn) );\r
 \r
@@ -403,7 +407,7 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
                          ofn.lpstrFilter = filter;\r
                          ofn.lpstrFile = buf;\r
                          ofn.nMaxFile = sizeof(buf);\r
-                         ofn.lpstrTitle = "Choose Book";\r
+                         ofn.lpstrTitle = _("Choose Book");\r
                          ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;\r
 \r
                          if( GetOpenFileName( &ofn ) ) {\r