summaryrefslogtreecommitdiff
path: root/xditview.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-14 12:42:33 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-14 16:12:24 -0800
commit0ca4db4996abd5e6161567575fe318663d8dd117 (patch)
tree80617e77b53fc9963d96c44e17c5f42a7ef4fbc3 /xditview.c
parent42e0ce4adc008430e32c54a5374b7744c2c2cfe4 (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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/xditview.c b/xditview.c
index 39abcea..6faa415 100644
--- a/xditview.c
+++ b/xditview.c
@@ -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);