From: Eric Leblond Date: Thu, 19 Apr 2018 12:32:51 +0000 (+0200) Subject: app-layer-ftp: fill direction of transfer X-Git-Tag: suricata-4.1.0-rc1~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2515c8927b3933b1924ebcb3a47696a0f3eda36e;p=thirdparty%2Fsuricata.git app-layer-ftp: fill direction of transfer This is required to return the file when asked with one direction. --- diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 700422db50..1da11b9f55 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -733,6 +733,16 @@ static int FTPDataParse(Flow *f, FtpDataState *ftpdata_state, data->file_len = 0; f->parent_id = data->flow_id; ftpdata_state->command = data->cmd; + switch (data->cmd) { + case FTP_COMMAND_STOR: + ftpdata_state->direction = STREAM_TOSERVER; + break; + case FTP_COMMAND_RETR: + ftpdata_state->direction = STREAM_TOCLIENT; + break; + default: + break; + } if (FileOpenFile(ftpdata_state->files, &sbcfg, (uint8_t *) ftpdata_state->file_name, @@ -883,6 +893,9 @@ static FileContainer *FTPDataStateGetFiles(void *state, uint8_t direction) { FtpDataState *ftpdata_state = (FtpDataState *)state; + if (direction != ftpdata_state->direction) + SCReturnPtr(NULL, "FileContainer"); + SCReturnPtr(ftpdata_state->files, "FileContainer"); }