aboutsummaryrefslogtreecommitdiff
path: root/libexec/ftpd/ftpd.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>1997-12-24 19:13:23 +0000
committerWarner Losh <imp@FreeBSD.org>1997-12-24 19:13:23 +0000
commite760ef2c3571b6ee1e785074a112a131b86b3c4c (patch)
tree564425c301b7e084becb022663ec2c83911188f3 /libexec/ftpd/ftpd.c
parent9bc34f7ce14c4401e6ee449f9eeb2c9222fbe756 (diff)
downloadsrc-e760ef2c3571b6ee1e785074a112a131b86b3c4c.tar.gz
src-e760ef2c3571b6ee1e785074a112a131b86b3c4c.zip
Various sprintf -> snprintf fixes.
Minor style fix (strcpy(foo,"") -> *foo = '\0') Obtained from: OpenBSD(?)
Notes
Notes: svn path=/head/; revision=31973
Diffstat (limited to 'libexec/ftpd/ftpd.c')
-rw-r--r--libexec/ftpd/ftpd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index df735aae1813..83c1727167bb 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -44,7 +44,7 @@ static char copyright[] =
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: ftpd.c,v 1.43 1997/11/21 07:38:42 charnier Exp $";
#endif /* not lint */
/*
@@ -483,7 +483,7 @@ main(argc, argv, envp)
data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1);
/* set this here so klogin can use it... */
- (void)sprintf(ttyline, "ftp%d", getpid());
+ (void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());
/* Try to handle urgent data inline */
#ifdef SO_OOBINLINE
@@ -1132,7 +1132,7 @@ retrieve(cmd, name)
} else {
char line[BUFSIZ];
- (void) sprintf(line, cmd, name), name = line;
+ (void) snprintf(line, sizeof(line), cmd, name), name = line;
fin = ftpd_popen(line, "r"), closefunc = ftpd_pclose;
st.st_size = -1;
st.st_blksize = BUFSIZ;
@@ -1333,9 +1333,9 @@ dataconn(name, size, mode)
file_size = size;
byte_count = 0;
if (size != (off_t) -1)
- (void) sprintf(sizebuf, " (%qd bytes)", size);
+ (void) snprintf(sizebuf, sizeof(sizebuf), " (%qd bytes)", size);
else
- (void) strcpy(sizebuf, "");
+ *sizebuf = '\0';
if (pdata >= 0) {
struct sockaddr_in from;
int s, fromlen = sizeof(from);
@@ -2059,7 +2059,8 @@ gunique(local)
}
if (cp)
*cp = '/';
- (void) snprintf(new, sizeof(new), "%s", local);
+ /* -4 is for the .nn<null> we put on the end below */
+ (void) snprintf(new, sizeof(new) - 4, "%s", local);
cp = new + strlen(new);
*cp++ = '.';
for (count = 1; count < 100; count++) {
@@ -2172,7 +2173,8 @@ send_file_list(whichf)
dir->d_namlen == 2)
continue;
- sprintf(nbuf, "%s/%s", dirname, dir->d_name);
+ snprintf(nbuf, sizeof(nbuf),
+ "%s/%s", dirname, dir->d_name);
/*
* We have to do a stat to insure it's