Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions rust/src/detect/datasets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

//! This module exposes items from the datasets C code to Rust.

use crate::ffi::hashing::{SC_MD5_LEN, SC_SHA256_LEN};
use base64::{self, Engine};
use std::ffi::{c_char, CStr};
use std::fs::{File, OpenOptions};
Expand Down Expand Up @@ -168,12 +169,15 @@ unsafe fn process_md5_set(
Ok(rs) => rs,
Err(_) => return -1,
};
if md5_string.len() != SC_MD5_LEN {
return -1;
}

if no_rep {
DatasetAdd(set, md5_string.as_ptr(), 16);
DatasetAdd(set, md5_string.as_ptr(), SC_MD5_LEN as u32);
} else if let Ok(val) = v[1].to_string().parse::<u16>() {
let rep: DataRepType = DataRepType { value: val };
DatasetAddwRep(set, md5_string.as_ptr(), 16, &rep);
DatasetAddwRep(set, md5_string.as_ptr(), SC_MD5_LEN as u32, &rep);
} else {
SCFatalErrorOnInit!(
"invalid datarep value {} in {}",
Expand All @@ -192,12 +196,15 @@ unsafe fn process_sha256_set(
Ok(rs) => rs,
Err(_) => return -1,
};
if sha256_string.len() != SC_SHA256_LEN {
return -1;
}

if no_rep {
DatasetAdd(set, sha256_string.as_ptr(), 32);
DatasetAdd(set, sha256_string.as_ptr(), SC_SHA256_LEN as u32);
} else if let Ok(val) = v[1].to_string().parse::<u16>() {
let rep: DataRepType = DataRepType { value: val };
DatasetAddwRep(set, sha256_string.as_ptr(), 32, &rep);
DatasetAddwRep(set, sha256_string.as_ptr(), SC_SHA256_LEN as u32, &rep);
} else {
SCFatalErrorOnInit!(
"invalid datarep value {} in {}",
Expand Down
3 changes: 2 additions & 1 deletion rust/src/nfs/nfs3_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ pub fn parse_nfs3_request_write(i: &[u8], complete: bool) -> IResult<&[u8], Nfs3
pub fn parse_nfs3_reply_read(i: &[u8], complete: bool) -> IResult<&[u8], NfsReplyRead<'_>> {
let (i, status) = be_u32(i)?;
let (i, attr_follows) = verify(be_u32, |&v| v <= 1)(i)?;
let (i, attr_blob) = take(84_usize)(i)?; // fixed size?
let (i, attr_blob_opt) = cond(attr_follows == 1, take(84_usize))(i)?;
let attr_blob = attr_blob_opt.unwrap_or(&[]);
let (i, count) = be_u32(i)?;
let (i, eof) = verify(be_u32, |&v| v <= 1)(i)?;
let (i, data_len) = verify(be_u32, |&v| v <= count)(i)?;
Expand Down
4 changes: 3 additions & 1 deletion src/detect-engine-frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ static int FrameStreamDataInspectFunc(
// PrintRawDataFp(stdout, data, data_len);
// PrintRawDataFp(stdout, data, MIN(64, data_len));
#endif
DEBUG_VALIDATE_BUG_ON(fsd->frame->len > 0 && (int64_t)data_len > fsd->frame->len);
// Only assert if the engine does not have transforms that may grow the buffer
DEBUG_VALIDATE_BUG_ON(fsd->frame->len > 0 && (int64_t)data_len > fsd->frame->len &&
engine->sm_list == engine->sm_list_base);

const bool match = DetectEngineContentInspection(det_ctx->de_ctx, det_ctx, s, engine->smd, p,
p->flow, data, data_len, data_offset, buffer->flags,
Expand Down
Loading