-/* $OpenBSD: ftp.c,v 1.84 2013/12/20 13:44:51 jca Exp $ */
+/* $OpenBSD: ftp.c,v 1.85 2014/04/22 20:48:41 tedu Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
if (data_addr.su_family != AF_INET) {
fputs(
"Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
- error = 1;
goto bad;
}
if (code / 10 == 22 && code != 227) {
fputs("wrong server: return code must be 227\n",
ttyout);
- error = 1;
goto bad;
}
error = sscanf(pasv, "%u,%u,%u,%u,%u,%u",
if (error != 6) {
fputs(
"Passive mode address scan failure. Shouldn't happen!\n", ttyout);
- error = 1;
goto bad;
}
- error = 0;
memset(&data_addr, 0, sizeof(data_addr));
data_addr.su_family = AF_INET;
data_addr.su_len = sizeof(struct sockaddr_in);
if (code / 10 == 22 && code != 228) {
fputs("wrong server: return code must be 228\n",
ttyout);
- error = 1;
goto bad;
}
switch (data_addr.su_family) {
if (error != 9) {
fputs(
"Passive mode address scan failure. Shouldn't happen!\n", ttyout);
- error = 1;
goto bad;
}
if (af != 4 || hal != 4 || pal != 2) {
goto bad;
}
- error = 0;
memset(&data_addr, 0, sizeof(data_addr));
data_addr.su_family = AF_INET;
data_addr.su_len = sizeof(struct sockaddr_in);
if (error != 21) {
fputs(
"Passive mode address scan failure. Shouldn't happen!\n", ttyout);
- error = 1;
goto bad;
}
if (af != 6 || hal != 16 || pal != 2) {
fputs(
"Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
- error = 1;
goto bad;
}
- error = 0;
memset(&data_addr, 0, sizeof(data_addr));
data_addr.su_family = AF_INET6;
data_addr.su_len = sizeof(struct sockaddr_in6);
data_addr.su_port = htons(pack2(port, 0));
break;
default:
- error = 1;
+ fputs("Bad family!\n", ttyout);
+ goto bad;
}
} else if (strcmp(pasvcmd, "EPSV") == 0) {
char delim[4];
if (code / 10 == 22 && code != 229) {
fputs("wrong server: return code must be 229\n",
ttyout);
- error = 1;
goto bad;
}
if (sscanf(pasv, "%c%c%c%d%c", &delim[0],
&delim[1], &delim[2], &port[1],
&delim[3]) != 5) {
fputs("parse error!\n", ttyout);
- error = 1;
goto bad;
}
if (delim[0] != delim[1] || delim[0] != delim[2]
|| delim[0] != delim[3]) {
fputs("parse error!\n", ttyout);
- error = 1;
goto bad;
}
data_addr = hisctladdr;