X11 buffer overflow avoidance

Don't overflow the buffer passed to getlin().
This commit is contained in:
cohrs
2002-01-23 06:21:58 +00:00
parent 84b72da0eb
commit a80a7ab939
+9 -1
View File
@@ -1210,12 +1210,20 @@ done_button(w, client_data, call_data)
XtPointer client_data; XtPointer client_data;
XtPointer call_data; XtPointer call_data;
{ {
int len;
char *s; char *s;
Widget dialog = (Widget) client_data; Widget dialog = (Widget) client_data;
s = (char *) GetDialogResponse(dialog); s = (char *) GetDialogResponse(dialog);
Strcpy(getline_input, s); len = strlen(s);
/* Truncate input if necessary */
if (len >= BUFSZ) len = BUFSZ - 1;
(void) strncpy(getline_input, s, len);
getline_input[len] = '\0';
XtFree(s); XtFree(s);
nh_XtPopdown(XtParent(dialog)); nh_XtPopdown(XtParent(dialog));
exit_x_event = TRUE; exit_x_event = TRUE;
} }