summaryrefslogtreecommitdiff
path: root/libexec/ftp-proxy/ftp-proxy.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2001-08-19 17:33:13 +0000
committerBob Beck <beck@cvs.openbsd.org>2001-08-19 17:33:13 +0000
commitc5719ec917e0489a1da210673ae1953c1a1d56e0 (patch)
tree82b120fce8a69b16e002b0fb41d812c82ce04a19 /libexec/ftp-proxy/ftp-proxy.c
parent9efa9cd8b2338e18ed67931b026d14af6f02e4f2 (diff)
decruftify
Diffstat (limited to 'libexec/ftp-proxy/ftp-proxy.c')
-rw-r--r--libexec/ftp-proxy/ftp-proxy.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/libexec/ftp-proxy/ftp-proxy.c b/libexec/ftp-proxy/ftp-proxy.c
index 41858efbcda..66f7f722fb2 100644
--- a/libexec/ftp-proxy/ftp-proxy.c
+++ b/libexec/ftp-proxy/ftp-proxy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp-proxy.c,v 1.8 2001/08/19 17:20:34 beck Exp $ */
+/* $OpenBSD: ftp-proxy.c,v 1.9 2001/08/19 17:33:12 beck Exp $ */
/*
* Copyright (c) 1996-2001
@@ -582,41 +582,20 @@ out:
strlen("port ")) == 0) {
unsigned int values[6];
int byte_number;
- u_char *tailptr, ch;
+ u_char *tailptr;
debuglog(1, "Got a PORT command\n");
tailptr = &client->line_buffer[strlen("port ")];
byte_number = 0;
values[0] = 0;
- while ((ch = *tailptr) == ',' || isdigit(ch)) {
- if (isdigit(ch)) {
- values[byte_number] = values[byte_number]
- * 10 + ch - '0';
- if (values[byte_number] > 255) {
- syslog(LOG_NOTICE, "%s %s %s",
- "ERROR - byte value greater",
- "than 255 in PORT command",
- "- terminating session");
- exit(EX_DATAERR);
- }
- } else if (ch == ',') {
- byte_number += 1;
- if (byte_number < 6)
- values[byte_number] = 0;
- else {
- syslog(LOG_NOTICE, "%s %s",
- "too many byte values in PORT",
- "command - terminating session");
- exit(EX_DATAERR);
- }
- }
- tailptr += 1;
- }
- if (byte_number != 5) {
- syslog(LOG_NOTICE, "Too few byte values in %s",
- "PORT command - session terminated");
+ i = sscanf(tailptr, "%u,%u,%u,%u,%u,%u", &values[0],
+ &values[1], &values[2], &values[3], &values[4],
+ &values[5]);
+ if (i != 6) {
+ syslog(LOG_INFO, "malformed PORT command (%s)",
+ client->line_buffer);
exit(EX_DATAERR);
}