break;
}
- if (FileOpenFile(ftpdata_state->files, &sbcfg,
- (uint8_t *) ftpdata_state->file_name,
+ /* open with fixed track_id 0 as we can have just one
+ * file per ftp-data flow. */
+ if (FileOpenFileWithId(ftpdata_state->files, &sbcfg,
+ 0ULL, (uint8_t *) ftpdata_state->file_name,
ftpdata_state->file_len,
- input, input_len, flags) == NULL) {
+ input, input_len, flags) != 0) {
SCLogDebug("Can't open file");
ret = -1;
}
sbcfg = &s->cfg->request.sbcfg;
}
- if (FileOpenFile(files, sbcfg, filename, filename_len,
- data, data_len, flags) == NULL)
+ if (FileOpenFileWithId(files, sbcfg, s->file_track_id++,
+ filename, filename_len,
+ data, data_len, flags) != 0)
{
retval = -1;
}
uint16_t flags;
uint16_t events;
uint16_t htp_messages_offset; /**< offset into conn->messages list */
+ uint32_t file_track_id; /**< used to assign file track ids to files */
uint64_t last_request_data_stamp;
uint64_t last_response_data_stamp;
} HtpState;
flags |= FILE_STORE;
}
- if (FileOpenFile(files, &smtp_config.sbcfg, (uint8_t *) entity->filename, entity->filename_len,
- (uint8_t *) chunk, len, flags) == NULL) {
+ if (FileOpenFileWithId(files, &smtp_config.sbcfg, smtp_state->file_track_id++,
+ (uint8_t *) entity->filename, entity->filename_len,
+ (uint8_t *) chunk, len, flags) != 0) {
ret = MIME_DEC_ERR_DATA;
SCLogDebug("FileOpenFile() failed");
}
TAILQ_INSERT_TAIL(&state->tx_list, tx, next);
tx->tx_id = state->tx_cnt++;
}
- FileOpenFile(state->files_ts, &smtp_config.sbcfg,
+ if (FileOpenFileWithId(state->files_ts, &smtp_config.sbcfg,
+ state->file_track_id++,
(uint8_t*) msgname, strlen(msgname), NULL, 0,
- FILE_NOMD5|FILE_NOMAGIC);
- FlagDetectStateNewFile(state->curr_tx);
+ FILE_NOMD5|FILE_NOMAGIC) == 0) {
+ FlagDetectStateNewFile(state->curr_tx);
+ }
} else if (smtp_config.decode_mime) {
if (tx->mime_state) {
/* We have 2 chained mails and did not detect the end
* handler */
uint16_t cmds_idx;
+ /* HELO of HELO message content */
+ uint16_t helo_len;
+ uint8_t *helo;
+
/* SMTP Mime decoding and file extraction */
/** the list of files sent to the server */
FileContainer *files_ts;
-
- /* HELO of HELO message content */
- uint8_t *helo;
- uint16_t helo_len;
+ uint32_t file_track_id;
} SMTPState;
/* Create SMTP config structure */
*
* \note filename is not a string, so it's not nul terminated.
*/
-File *FileOpenFile(FileContainer *ffc, const StreamingBufferConfig *sbcfg,
+static File *FileOpenFile(FileContainer *ffc, const StreamingBufferConfig *sbcfg,
const uint8_t *name, uint16_t name_len,
const uint8_t *data, uint32_t data_len, uint16_t flags)
{
* It's the responsibility of the API user to make sure this tracker is
* properly updated.
*/
-File *FileOpenFile(FileContainer *, const StreamingBufferConfig *,
- const uint8_t *name, uint16_t name_len,
- const uint8_t *data, uint32_t data_len, uint16_t flags);
int FileOpenFileWithId(FileContainer *, const StreamingBufferConfig *,
uint32_t track_id, const uint8_t *name, uint16_t name_len,
const uint8_t *data, uint32_t data_len, uint16_t flags);