=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/complete.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- src/usr.bin/ftp/complete.c 2001/03/09 17:01:02 1.10 +++ src/usr.bin/ftp/complete.c 2001/06/26 23:44:00 1.11 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ && 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));