ftp: fix reply without request

Permit picking up any reply w/o a request. Observed unsolicited server
messages before connection termination.

Previously the code assumed that this could only happen on connection
start when there was no previously recorded command.
pull/4046/head
Victor Julien 6 years ago
parent dc80d520af
commit b595da6c51

@ -752,24 +752,21 @@ static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstat
{ {
FtpState *state = (FtpState *)ftp_state; FtpState *state = (FtpState *)ftp_state;
int retcode = 1; int retcode = 1;
FTPTransaction *tx;
if (state->command == FTP_COMMAND_UNKNOWN) { if (unlikely(input_len == 0)) {
if (unlikely(input_len == 0)) { return 1;
return 1; }
}
tx = FTPGetOldestTx(state); FTPTransaction *tx = FTPGetOldestTx(state);
if (tx == NULL) { if (tx == NULL) {
tx = FTPTransactionCreate(state); tx = FTPTransactionCreate(state);
} }
if (unlikely(tx == NULL)) { if (unlikely(tx == NULL)) {
return -1; return -1;
} }
if (state->command == FTP_COMMAND_UNKNOWN || tx->command_descriptor == NULL) {
/* unknown */ /* unknown */
tx->command_descriptor = &FtpCommands[FTP_COMMAND_MAX -1]; tx->command_descriptor = &FtpCommands[FTP_COMMAND_MAX -1];
} else {
tx = FTPGetOldestTx(state);
} }
state->curr_tx = tx; state->curr_tx = tx;

Loading…
Cancel
Save