Bugfix for safeStrCpy patch for XBoard
[xboard.git] / xoptions.c
index b5368a3..2f58c7b 100644 (file)
@@ -1432,7 +1432,7 @@ void SettingsCallback(w, client_data, call_data)
                    XtSetArg(args[0], XtNstring, &val);
                    XtGetValues(currentCps->option[i].handle, args, 1);
                    if(strcmp(currentCps->option[i].textValue, val)) {
                    XtSetArg(args[0], XtNstring, &val);
                    XtGetValues(currentCps->option[i].handle, args, 1);
                    if(strcmp(currentCps->option[i].textValue, val)) {
-                     safeStrCpy(currentCps->option[i].textValue, val, sizeof(currentCps->option[i].textValue)/sizeof(currentCps->option[i].textValue[0]));
+                     safeStrCpy(currentCps->option[i].textValue, val, MSG_SIZ - (currentCps->option[i].textValue - currentCps->option[i].name) );
                      snprintf(buf, MSG_SIZ,  "option %s=%s\n", currentCps->option[i].name, val);
                      SendToProgram(buf, currentCps);
                    }
                      snprintf(buf, MSG_SIZ,  "option %s=%s\n", currentCps->option[i].name, val);
                      SendToProgram(buf, currentCps);
                    }