summaryrefslogtreecommitdiffstats
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1998-02-14 15:38:29 +0000
committersteve <steve@FreeBSD.org>1998-02-14 15:38:29 +0000
commit70962efd65ee573e2f10cb92a13b4b8efbc9da34 (patch)
tree5621efc951722306178069af7ef0c1b58b135f20 /usr.bin/ftp
parent5884281637a87a39ed7d26ef0776391846848d3a (diff)
downloadFreeBSD-src-70962efd65ee573e2f10cb92a13b4b8efbc9da34.zip
FreeBSD-src-70962efd65ee573e2f10cb92a13b4b8efbc9da34.tar.gz
Cleanup code so that long lines to be quoted don't get truncated.
PR: 5679 Reviewed by: Bruce Evans <bde@zeta.org.au>
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/cmds.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c
index b96f4c0..57b286b 100644
--- a/usr.bin/ftp/cmds.c
+++ b/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
-/* $Id: cmds.c,v 1.12 1997/12/13 20:38:12 pst Exp $ */
+/* $Id: cmds.c,v 1.13 1998/01/09 13:45:11 msmith Exp $ */
/* $NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $ */
/*
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$Id: cmds.c,v 1.12 1997/12/13 20:38:12 pst Exp $");
+__RCSID("$Id: cmds.c,v 1.13 1998/01/09 13:45:11 msmith Exp $");
__RCSID_SOURCE("$NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $");
#endif
#endif /* not lint */
@@ -1448,19 +1448,17 @@ quote1(initial, argc, argv)
int argc;
char *argv[];
{
- int i, len;
+ int i, len, len1;
char buf[BUFSIZ]; /* must be >= sizeof(line) */
- (void)strncpy(buf, initial, sizeof(buf) - 1);
- buf[sizeof(buf) - 1] = '\0';
- if (argc > 1) {
- len = strlen(buf);
- len += strlen(strncpy(&buf[len], argv[1],
- sizeof(buf) - len - 1));
- for (i = 2; i < argc && len < sizeof(buf); i++) {
- buf[len++] = ' ';
- len += strlen(strncpy(&buf[len], argv[i],
- sizeof(buf) - len) - 1);
+ len = snprintf(buf, sizeof(buf), "%s", initial);
+ if (len >= 0 && len < sizeof(buf)) {
+ for (i = 1; i < argc; i++) {
+ len1 = snprintf(&buf[len], sizeof(buf) - len,
+ i == 1 ? "%s" : " %s", argv[i]);
+ if (len1 < 0 || len1 > sizeof(buf) - len)
+ break;
+ len += len1;
}
}
if (command(buf) == PRELIM) {
OpenPOWER on IntegriCloud