diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-14 12:42:33 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-14 16:12:24 -0800 |
commit | 0ca4db4996abd5e6161567575fe318663d8dd117 (patch) | |
tree | 80617e77b53fc9963d96c44e17c5f42a7ef4fbc3 /xditview.c | |
parent | 42e0ce4adc008430e32c54a5374b7744c2c2cfe4 (diff) |
Replace strcpy() calls with strncpy() or memcpy()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xditview.c')
-rw-r--r-- | xditview.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -370,7 +370,8 @@ VisitFile(char *name, Boolean resetPage) n = name; XtSetArg(arg[1], XtNiconName, n); XtSetValues(toplevel, arg, 2); - strcpy(current_file_name, name); + strncpy(current_file_name, name, sizeof(current_file_name)); + current_file_name[sizeof(current_file_name) - 1] = '\0'; current_file = new_file; DisplayPageNumber(); } @@ -462,8 +463,10 @@ OpenFile(Widget entry, XtPointer name, XtPointer data) static void OpenFileAction(Widget w, XEvent *xev, String *s, Cardinal *c) { - if (current_file_name[0]) - strcpy(fileBuf, current_file_name); + if (current_file_name[0]) { + strncpy(fileBuf, current_file_name, sizeof(fileBuf)); + fileBuf[sizeof(fileBuf) - 1] = '\0'; + } else fileBuf[0] = '\0'; MakePrompt(toplevel, "File to open:", NewFile, fileBuf); |