Merge in SNORT/snort3 from ~DAVMCPHE/snort3:add_daq_api_parameter_checks to master
Squashed commit of the following:
commit
bbc8506425b0e322a327284b0d682d7ace3e18a6
Author: davis mcpherson <davmcphe@cisco.com>
Date: Tue Jan 28 09:09:13 2025 -0500
ftp_telnet: only add expected flows when the daq_msg fieldin the control packet is not null.
commit
58d45bda1ee4118c50d35987582807b02be075fe
Author: davis mcpherson <davmcphe@cisco.com>
Date: Fri Jan 24 15:20:27 2025 -0500
packet_io: check the DAQ_Msg_h parameter on api calls and return an error code when it is a null pointer
node->head = node->tail = nullptr;
node->count = 0;
last = nullptr;
- /* Only add TCP and UDP expected flows for now via the DAQ module. */
- if ((ip_proto == IpProtocol::TCP || ip_proto == IpProtocol::UDP) && ctrlPkt->daq_instance)
+ // Only add TCP and UDP expected flows for now via the DAQ module. Additionally only
+ // add the expected flow when the daq_msg field is non-null. A null daq_msg field
+ // indicates the flow is closing and it is too late to add an expected flow.
+ if ((ip_proto == IpProtocol::TCP || ip_proto == IpProtocol::UDP) && ctrlPkt->daq_msg)
{
if (PacketTracer::is_active())
{
int SFDAQInstance::finalize_message(DAQ_Msg_h msg, DAQ_Verdict verdict)
{
+ if ( !msg )
+ return DAQ_ERROR_INVAL;
+
int rval = daq_instance_msg_finalize(instance, msg, verdict);
if (rval == DAQ_SUCCESS)
pool_available++;
int SFDAQInstance::inject(DAQ_Msg_h msg, int rev, const uint8_t* buf, uint32_t len)
{
+ if ( !msg )
+ return DAQ_ERROR_INVAL;
+
int rval = daq_instance_inject_relative(instance, msg, buf, len, rev);
#ifdef DEBUG_MSGS
if (rval != DAQ_SUCCESS)
int SFDAQInstance::modify_flow_opaque(DAQ_Msg_h msg, uint32_t opaque)
{
+ if ( !msg )
+ return DAQ_ERROR_INVAL;
+
DIOCTL_SetFlowOpaque d_sfo;
d_sfo.msg = msg;
d_sfo.value = opaque;
int SFDAQInstance::set_packet_verdict_reason(DAQ_Msg_h msg, uint8_t verdict_reason)
{
+ if ( !msg )
+ return DAQ_ERROR_INVAL;
+
DIOCTL_SetPacketVerdictReason d_spvr;
d_spvr.msg = msg;
int SFDAQInstance::set_packet_trace_data(DAQ_Msg_h msg, uint8_t* buff, uint32_t buff_len)
{
+ if ( !msg )
+ return DAQ_ERROR_INVAL;
+
DIOCTL_SetPacketTraceData d_sptd;
d_sptd.msg = msg;
#include "detection/detection_engine.h"
#include "log/log.h"
+#include "main/analyzer.h"
#include "packet_io/active.h"
#include "packet_io/packet_tracer.h"
+#include "packet_io/sfdaq.h"
#include "profiler/profiler.h"
#include "protocols/packet_manager.h"
#include "stream/stream_splitter.h"
static Packet* get_packet(Flow* flow, uint32_t flags, bool c2s)
{
Packet* p = DetectionEngine::set_next_packet(nullptr, flow);
-
DAQ_PktHdr_t* ph = p->context->pkth;
memset(ph, 0, sizeof(*ph));
packet_gettimeofday(&ph->ts);
+ if ( !p->daq_instance )
+ p->daq_instance = SFDAQ::get_local_instance();
p->pktlen = 0;
p->data = nullptr;
p->dsize = 0;