summaryrefslogtreecommitdiffstats
path: root/sys/netinet/libalias/alias_ftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/libalias/alias_ftp.c')
-rw-r--r--sys/netinet/libalias/alias_ftp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/netinet/libalias/alias_ftp.c b/sys/netinet/libalias/alias_ftp.c
index d5978f9..e2152ee 100644
--- a/sys/netinet/libalias/alias_ftp.c
+++ b/sys/netinet/libalias/alias_ftp.c
@@ -59,6 +59,9 @@
#define FTP_CONTROL_PORT_NUMBER 21
#define MAX_MESSAGE_SIZE 128
+/* FTP protocol flags. */
+#define WAIT_CRLF 0x01
+
enum ftp_message_type {
FTP_PORT_COMMAND,
FTP_EPRT_COMMAND,
@@ -82,7 +85,7 @@ struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link, /* The link to go through (aliased port) */
int maxpacketsize /* The maximum size this packet can grow to (including headers) */)
{
- int hlen, tlen, dlen;
+ int hlen, tlen, dlen, pflags;
char *sptr;
struct tcphdr *tc;
int ftp_message_type;
@@ -101,7 +104,8 @@ int maxpacketsize /* The maximum size this packet can grow to (including header
* Check that data length is not too long and previous message was
* properly terminated with CRLF.
*/
- if (dlen <= MAX_MESSAGE_SIZE && GetLastLineCrlfTermed(link)) {
+ pflags = GetProtocolFlags(link);
+ if (dlen <= MAX_MESSAGE_SIZE && (pflags & WAIT_CRLF)) {
ftp_message_type = FTP_UNKNOWN_MESSAGE;
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER) {
@@ -131,8 +135,11 @@ int maxpacketsize /* The maximum size this packet can grow to (including header
if (dlen) { /* only if there's data */
sptr = (char *) pip; /* start over at beginning */
tlen = ntohs(pip->ip_len); /* recalc tlen, pkt may have grown */
- SetLastLineCrlfTermed(link,
- (sptr[tlen-2] == '\r') && (sptr[tlen-1] == '\n'));
+ if (sptr[tlen-2] == '\r' && sptr[tlen-1] == '\n')
+ pflags &= ~WAIT_CRLF;
+ else
+ pflags |= WAIT_CRLF;
+ SetProtocolFlags(link, pflags);
}
}
OpenPOWER on IntegriCloud