summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-08-03 22:43:17 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-08-03 22:43:17 +0000
commitb33b8926939f770fb2c64241ecea527d63e3bb06 (patch)
tree8afda6b4fff2a099297c4f4c85e3640d65734613 /usr.bin
parent42a82d4aa73cebe940aa4d4d2f69e14c25bef5f5 (diff)
Add back NUL termination of 'word' in complete() that was erroneously
removed in strlcpy() conversion. Previously we were trying to strlcpy() a pointer that could be NULL. Now we check that the length != 0 and use memcpy() instead, then NUL terminate by hand to catch the other cases. Core dump noticed by fgs@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/complete.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c
index 7c35659a986..fe6d0fe33e2 100644
--- a/usr.bin/ftp/complete.c
+++ b/usr.bin/ftp/complete.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: complete.c,v 1.11 2001/06/26 23:44:00 lebel Exp $ */
+/* $OpenBSD: complete.c,v 1.12 2001/08/03 22:43:16 millert Exp $ */
/* $NetBSD: complete.c,v 1.10 1997/08/18 10:20:18 lukem Exp $ */
/*-
@@ -39,7 +39,7 @@
#ifndef SMALL
#ifndef lint
-static char rcsid[] = "$OpenBSD: complete.c,v 1.11 2001/06/26 23:44:00 lebel Exp $";
+static char rcsid[] = "$OpenBSD: complete.c,v 1.12 2001/08/03 22:43:16 millert Exp $";
#endif /* not lint */
/*
@@ -328,8 +328,9 @@ complete(el, ch)
if (lastc_argc == cursor_argc && lastc_argo == cursor_argo
&& strncmp(word, margv[cursor_argc], cursor_argo) == 0)
dolist = 1;
- else
- (void)strlcpy(word, margv[cursor_argc], cursor_argo+1);
+ else if (cursor_argo)
+ memcpy(word, margv[cursor_argc], cursor_argo);
+ word[cursor_argo] = '\0';
if (cursor_argc == 0)
return (complete_command(word, dolist));