Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports/60x/v3 #10885

Closed
wants to merge 7 commits into from
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
6 changes: 3 additions & 3 deletions rust/src/asn1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Asn1<'a>(Vec<BerObject<'a>>);
enum Asn1DecodeError {
InvalidKeywordParameter,
MaxFrames,
BerError(nom::Err<der_parser::error::BerError>),
BerError,
}

/// Enumeration of Asn1 checks
Expand Down Expand Up @@ -276,8 +276,8 @@ impl From<std::num::TryFromIntError> for Asn1DecodeError {
}

impl From<nom::Err<der_parser::error::BerError>> for Asn1DecodeError {
fn from(e: nom::Err<der_parser::error::BerError>) -> Asn1DecodeError {
Asn1DecodeError::BerError(e)
fn from(_e: nom::Err<der_parser::error::BerError>) -> Asn1DecodeError {
Asn1DecodeError::BerError
}
}

Expand Down
3 changes: 1 addition & 2 deletions rust/src/mqtt/mqtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,7 @@ export_tx_data_get!(rs_mqtt_get_tx_data, MQTTTransaction);
#[no_mangle]
pub unsafe extern "C" fn rs_mqtt_register_parser(cfg_max_msg_len: u32) {
let default_port = CString::new("[1883]").unwrap();
let max_msg_len = &mut MAX_MSG_LEN;
*max_msg_len = cfg_max_msg_len;
MAX_MSG_LEN = cfg_max_msg_len;
let parser = RustParser {
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
default_port: default_port.as_ptr(),
Expand Down
15 changes: 13 additions & 2 deletions src/conf-yaml-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,19 @@ ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int rlevel)
if (inseq) {
char sequence_node_name[DEFAULT_NAME_LEN];
snprintf(sequence_node_name, DEFAULT_NAME_LEN, "%d", seq_idx++);
ConfNode *seq_node = ConfNodeLookupChild(node,
sequence_node_name);
ConfNode *seq_node = NULL;
if (was_empty < 0) {
// initialize was_empty
if (TAILQ_EMPTY(&node->head)) {
was_empty = 1;
} else {
was_empty = 0;
}
}
// we only check if the node's list was not empty at first
if (was_empty == 0) {
seq_node = ConfNodeLookupChild(node, sequence_node_name);
}
if (seq_node != NULL) {
/* The sequence node has already been set, probably
* from the command line. Remove it so it gets
Expand Down
1 change: 0 additions & 1 deletion src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, u
p->recursion_level = parent->recursion_level; /* NOT incremented */
p->ts.tv_sec = parent->ts.tv_sec;
p->ts.tv_usec = parent->ts.tv_usec;
p->datalink = DLT_RAW;
p->tenant_id = parent->tenant_id;
/* tell new packet it's part of a tunnel */
SET_TUNNEL_PKT(p);
Expand Down
1 change: 1 addition & 0 deletions src/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ void DecodeUnregisterCounters(void);
* Libpcap on at least OpenBSD returns 101 as datalink type for RAW pcaps though. */
#define LINKTYPE_RAW2 101
#define LINKTYPE_IPV4 228
#define LINKTYPE_IPV6 229
#define LINKTYPE_GRE_OVER_IP 778
#define LINKTYPE_CISCO_HDLC DLT_C_HDLC
#define PPP_OVER_GRE 11
Expand Down
7 changes: 6 additions & 1 deletion src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Defrag4Reassemble(ThreadVars *tv, DefragTracker *tracker, Packet *p)
}
PKT_SET_SRC(rp, PKT_SRC_DEFRAG);
rp->flags |= PKT_REBUILT_FRAGMENT;
rp->recursion_level = p->recursion_level;
rp->datalink = tracker->datalink;

int fragmentable_offset = 0;
int fragmentable_len = 0;
Expand Down Expand Up @@ -433,6 +433,8 @@ Defrag6Reassemble(ThreadVars *tv, DefragTracker *tracker, Packet *p)
goto error_remove_tracker;
}
PKT_SET_SRC(rp, PKT_SRC_DEFRAG);
rp->flags |= PKT_REBUILT_FRAGMENT;
rp->datalink = tracker->datalink;

int unfragmentable_len = 0;
int fragmentable_offset = 0;
Expand Down Expand Up @@ -861,6 +863,9 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
#ifdef DEBUG
new->pcap_cnt = pcap_cnt;
#endif
if (frag_offset == 0) {
tracker->datalink = p->datalink;
}

IP_FRAGMENTS_RB_INSERT(&tracker->fragment_tree, new);

Expand Down
1 change: 1 addition & 0 deletions src/defrag.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef struct DefragTracker_ {
Address dst_addr; /**< Destination address for this tracker. */

struct timeval timeout; /**< When this tracker will timeout. */
int datalink; /**< datalink for reassembled packet, set by first fragment */
uint32_t host_timeout; /**< Host timeout, statically assigned from the yaml */

/** use cnt, reference counter */
Expand Down
1 change: 1 addition & 0 deletions src/source-pcap-file-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ TmEcode ValidateLinkType(int datalink, DecoderFunc *DecoderFn)
*DecoderFn = DecodePPP;
break;
case LINKTYPE_IPV4:
case LINKTYPE_IPV6:
case LINKTYPE_RAW:
case LINKTYPE_RAW2:
case LINKTYPE_GRE_OVER_IP:
Expand Down
1 change: 1 addition & 0 deletions src/tests/detect-http-client-body.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ static int RunTest (struct TestSteps *steps, const char *sig, const char *yaml)
int i = 0;
while (b->input != NULL) {
SCLogDebug("chunk %p %d", b, i);
(void)i;
Packet *p = UTHBuildPacket(NULL, 0, IPPROTO_TCP);
FAIL_IF_NULL(p);
p->flow = &f;
Expand Down
1 change: 1 addition & 0 deletions src/tests/detect-http-server-body.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static int RunTest(struct TestSteps *steps, const char *sig, const char *yaml)
int i = 0;
while (b->input != NULL) {
SCLogDebug("chunk %p %d", b, i);
(void)i;
Packet *p = UTHBuildPacket(NULL, 0, IPPROTO_TCP);
FAIL_IF_NULL(p);
p->flow = &f;
Expand Down
Loading