summaryrefslogtreecommitdiff
path: root/usr.bin/ftp/complete.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/ftp/complete.c')
-rw-r--r--usr.bin/ftp/complete.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c
index ba5f02e6d85..7c35659a986 100644
--- a/usr.bin/ftp/complete.c
+++ b/usr.bin/ftp/complete.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: complete.c,v 1.10 2001/03/09 17:01:02 millert Exp $ */
+/* $OpenBSD: complete.c,v 1.11 2001/06/26 23:44:00 lebel 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.10 2001/03/09 17:01:02 millert Exp $";
+static char rcsid[] = "$OpenBSD: complete.c,v 1.11 2001/06/26 23:44:00 lebel Exp $";
#endif /* not lint */
/*
@@ -113,8 +113,7 @@ complete_ambiguous(word, list, words)
matchlen = j;
}
if (matchlen > wordlen) {
- (void)strncpy(insertstr, lastmatch, matchlen);
- insertstr[matchlen] = '\0';
+ (void)strlcpy(insertstr, lastmatch, matchlen+1);
if (el_insertstr(el, insertstr + wordlen) == -1)
return (CC_ERROR);
else
@@ -183,8 +182,7 @@ complete_local(word, list)
dir[0] = '/';
dir[1] = '\0';
} else {
- (void)strncpy(dir, word, (size_t)(file - word));
- dir[file - word] = '\0';
+ (void)strlcpy(dir, word, (size_t)(file - word) + 1);
}
file++;
}
@@ -241,8 +239,7 @@ complete_remote(word, list)
cp = file;
while (*cp == '/' && cp > word)
cp--;
- (void)strncpy(dir, word, (size_t)(cp - word + 1));
- dir[cp - word + 1] = '\0';
+ (void)strlcpy(dir, word, (size_t)(cp - word + 2));
file++;
}
@@ -317,8 +314,7 @@ complete(el, ch)
len = lf->lastchar - lf->buffer;
if (len >= sizeof(line))
return (CC_ERROR);
- (void)strncpy(line, lf->buffer, len);
- line[len] = '\0';
+ (void)strlcpy(line, lf->buffer, len+1);
cursor_pos = line + (lf->cursor - lf->buffer);
lastc_argc = cursor_argc; /* remember last cursor pos */
lastc_argo = cursor_argo;
@@ -333,8 +329,7 @@ complete(el, ch)
&& strncmp(word, margv[cursor_argc], cursor_argo) == 0)
dolist = 1;
else
- (void)strncpy(word, margv[cursor_argc], cursor_argo);
- word[cursor_argo] = '\0';
+ (void)strlcpy(word, margv[cursor_argc], cursor_argo+1);
if (cursor_argc == 0)
return (complete_command(word, dolist));