Skip to content

Commit

Permalink
file/htp: Add logic for file access
Browse files Browse the repository at this point in the history
Set file inspection sizes and marker for use with detect logic when
opening files by name or as part of a range.

Issue: 4145
  • Loading branch information
jlucovsky authored and victorjulien committed Jul 14, 2023
1 parent 82b585d commit f2e2576
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app-layer-htp-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ int HTPFileOpen(HtpState *s, HtpTxUserData *tx, const uint8_t *filename, uint16_
flags = FileFlowFlagsToFlags(tx->tx_data.file_flags, STREAM_TOSERVER);
}

flags |= FILE_USE_DETECT;

if (FileOpenFileWithId(files, &htp_sbcfg, s->file_track_id++, filename, filename_len, data,
data_len, flags) != 0) {
retval = -1;
} else {
const HTPCfgDir *cfg;
if (direction & STREAM_TOCLIENT) {
cfg = &s->cfg->response;
} else {
cfg = &s->cfg->request;
}
FileSetInspectSizes(files->tail, cfg->inspect_window, cfg->inspect_min_size);
}

tx->tx_data.files_opened++;
Expand Down Expand Up @@ -156,10 +166,15 @@ int HTPFileOpenWithRange(HtpState *s, HtpTxUserData *txud, const uint8_t *filena
flags = FileFlowToFlags(s->f, STREAM_TOCLIENT);
FileContainer *files = &txud->files_tc;

flags |= FILE_USE_DETECT;

// we open a file for this specific range
if (FileOpenFileWithId(files, &htp_sbcfg, s->file_track_id++, filename, filename_len, data,
data_len, flags) != 0) {
SCReturnInt(-1);
} else {
const HTPCfgDir *cfg = &s->cfg->response;
FileSetInspectSizes(files->tail, cfg->inspect_window, cfg->inspect_min_size);
}
txud->tx_data.files_opened++;

Expand Down

0 comments on commit f2e2576

Please sign in to comment.