summaryrefslogtreecommitdiff
path: root/usr.sbin/faithd/ftp.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-20 16:32:54 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-20 16:32:54 +0000
commit865faff95d195731bc635a0ecb6b82240bdf01ad (patch)
tree583eded31cf49fa2f3eda4a89d21d11147538c07 /usr.sbin/faithd/ftp.c
parent05d299e7b204e7e1df159eed593901871dbe66da (diff)
rcsid police.
pathname change (/usr/local/v6/libexec -> /usr/libexec) bring in some of kame fixes (sprintf -> snprintf, proc title).
Diffstat (limited to 'usr.sbin/faithd/ftp.c')
-rw-r--r--usr.sbin/faithd/ftp.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/usr.sbin/faithd/ftp.c b/usr.sbin/faithd/ftp.c
index 96258f32e19..28eced1b716 100644
--- a/usr.sbin/faithd/ftp.c
+++ b/usr.sbin/faithd/ftp.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: ftp.c,v 1.2 1999/12/20 16:32:53 itojun Exp $ */
+
/*
* Copyright (C) 1997 and 1998 WIDE Project.
* All rights reserved.
@@ -402,7 +404,7 @@ ftp_copyresult(int src, int dst, enum state state)
case NONE:
if (!passivemode && rbuf[0] == '1') {
if (ftp_activeconn() < 0) {
- n = sprintf(rbuf,
+ n = snprintf(rbuf, sizeof(rbuf),
"425 Cannot open data connetion\r\n");
}
}
@@ -495,7 +497,7 @@ passivefail0:
wport6 = socket(sin6->sin6_family, SOCK_STREAM, 0);
if (wport6 == -1) {
passivefail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate from PASV\r\n");
write(src, sbuf, n);
return n;
@@ -551,7 +553,7 @@ passivefail:
a = (char *)&sin6->sin6_addr;
p = (char *)&sin6->sin6_port;
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"228 Entering Long Passive Mode (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n",
6, 16, UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(a[4]), UC(a[5]), UC(a[6]), UC(a[7]),
@@ -562,7 +564,7 @@ passivefail:
passivemode = 1;
return n;
} else {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"229 Entering Extended Passive Mode (|||%d|)\r\n",
ntohs(sin6->sin6_port));
write(dst, sbuf, n);
@@ -616,7 +618,7 @@ passivefail1:
wport6 = socket(sin->sin_family, SOCK_STREAM, 0);
if (wport6 == -1) {
passivefail2:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate from EPSV\r\n");
write(src, sbuf, n);
return n;
@@ -672,7 +674,7 @@ passivefail2:
a = (char *)&sin->sin_addr;
p = (char *)&sin->sin_port;
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1]));
@@ -776,7 +778,7 @@ ftp_copycommand(int src, int dst, enum state *state)
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
@@ -790,7 +792,7 @@ ftp_copycommand(int src, int dst, enum state *state)
&ho[12], &ho[13], &ho[14], &ho[15],
&pal, &po[0], &po[1]);
if (n != 21 || af != 6 || hal != 16|| pal != 2) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to LPRT\r\n");
write(src, sbuf, n);
return n;
@@ -811,7 +813,7 @@ sendport:
error = getsockname(dst, (struct sockaddr *)&data4, &n);
if (error == -1) {
lprtfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate to PORT\r\n");
write(src, sbuf, n);
return n;
@@ -852,7 +854,7 @@ lprtfail:
sin = (struct sockaddr_in *)&data4;
a = (char *)&sin->sin_addr;
p = (char *)&sin->sin_port;
- n = sprintf(sbuf, "PORT %d,%d,%d,%d,%d,%d\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "PORT %d,%d,%d,%d,%d,%d\r\n",
UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
UC(p[0]), UC(p[1]));
write(dst, sbuf, n);
@@ -875,7 +877,7 @@ lprtfail:
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
@@ -888,7 +890,7 @@ lprtfail:
p++;
if (!*p) {
eprtparamfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -909,7 +911,7 @@ eprtparamfail:
n = sscanf(afp, "%d", &af);
if (n != 1 || af != 2) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 unsupported address family to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -918,13 +920,13 @@ eprtparamfail:
hints.ai_family = AF_UNSPEC;
error = getaddrinfo(hostp, portp, &hints, &res);
if (error) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 EPRT: %s\r\n", gai_strerror(error));
write(src, sbuf, n);
return n;
}
if (res->ai_next) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 EPRT: %s resolved to multiple addresses\r\n", hostp);
write(src, sbuf, n);
return n;
@@ -946,14 +948,14 @@ eprtparamfail:
wport4 = wport6 = port4 = port6 = -1;
if (epsvall) {
- n = sprintf(sbuf, "501 %s disallowed in EPSV ALL\r\n",
+ n = snprintf(sbuf, sizeof(sbuf), "501 %s disallowed in EPSV ALL\r\n",
cmd);
write(src, sbuf, n);
return n;
}
/* transmit PASV */
- n = sprintf(sbuf, "PASV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "PASV\r\n");
write(dst, sbuf, n);
*state = LPSV;
passivemode = 0; /* to be set to 1 later */
@@ -968,7 +970,7 @@ eprtparamfail:
close(port6);
wport4 = wport6 = port4 = port6 = -1;
- n = sprintf(sbuf, "PASV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "PASV\r\n");
write(dst, sbuf, n);
*state = EPSV;
passivemode = 0; /* to be set to 1 later */
@@ -979,7 +981,7 @@ eprtparamfail:
* EPSV ALL
*/
epsvall = 1;
- n = sprintf(sbuf, "200 EPSV ALL command successful.\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "200 EPSV ALL command successful.\r\n");
write(src, sbuf, n);
return n;
#ifdef FAITH4
@@ -1001,7 +1003,7 @@ eprtparamfail:
n = sscanf(p, "%u,%u,%u,%u,%u,%u",
&ho[0], &ho[1], &ho[2], &ho[3], &po[0], &po[1]);
if (n != 6) {
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"501 illegal parameter to PORT\r\n");
write(src, sbuf, n);
return n;
@@ -1021,7 +1023,7 @@ eprtparamfail:
error = getsockname(dst, (struct sockaddr *)&data4, &n);
if (error == -1) {
portfail:
- n = sprintf(sbuf,
+ n = snprintf(sbuf, sizeof(sbuf),
"500 could not translate to EPRT\r\n");
write(src, sbuf, n);
return n;
@@ -1063,7 +1065,7 @@ portfail:
wport4 = -1;
goto portfail;
}
- n = sprintf(sbuf, "EPRT |%d|%s|%s|\r\n", af, host, serv);
+ n = snprintf(sbuf, sizeof(sbuf), "EPRT |%d|%s|%s|\r\n", af, host, serv);
write(dst, sbuf, n);
*state = nstate;
passivemode = 0;
@@ -1082,7 +1084,7 @@ portfail:
wport4 = wport6 = port4 = port6 = -1;
/* transmit EPSV */
- n = sprintf(sbuf, "EPSV\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "EPSV\r\n");
write(dst, sbuf, n);
*state = PASV;
passivemode = 0; /* to be set to 1 later */
@@ -1092,7 +1094,7 @@ portfail:
/*
* reject PORT/PASV
*/
- n = sprintf(sbuf, "502 %s not implemented.\r\n", cmd);
+ n = snprintf(sbuf, sizeof(sbuf), "502 %s not implemented.\r\n", cmd);
write(src, sbuf, n);
return n;
#endif /* FAITH4 */
@@ -1109,7 +1111,7 @@ portfail:
*/
if (ftp_passiveconn() < 0) {
- n = sprintf(sbuf, "425 Cannot open data connetion\r\n");
+ n = snprintf(sbuf, sizeof(sbuf), "425 Cannot open data connetion\r\n");
write(src, sbuf, n);
} else {
/* simply relay the command */