#include "detect-engine-content-inspection.h"
#include "detect-fast-pattern.h"
#include "detect-icmpv6hdr.h"
+#include "util-validate.h"
/* prototypes */
static int DetectICMPv6hdrSetup (DetectEngineCtx *, Signature *, const char *);
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
uint32_t hlen = ICMPV6_HEADER_LEN;
+ DEBUG_VALIDATE_BUG_ON(p->icmpv6h == NULL);
if (((uint8_t *)p->icmpv6h + (ptrdiff_t)hlen) >
((uint8_t *)GET_PKT_DATA(p) + (ptrdiff_t)GET_PKT_LEN(p)))
{
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
+ if (p->ip4h == NULL) {
+ // DETECT_PROTO_IPV4 does not prefilter
+ return NULL;
+ }
uint32_t hlen = IPV4_GET_HLEN(p);
if (((uint8_t *)p->ip4h + (ptrdiff_t)hlen) >
((uint8_t *)GET_PKT_DATA(p) + (ptrdiff_t)GET_PKT_LEN(p)))
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
+ if (p->ip6h == NULL) {
+ // DETECT_PROTO_IPV6 does not prefilter
+ return NULL;
+ }
uint32_t hlen = IPV6_HEADER_LEN + IPV6_GET_EXTHDRS_LEN(p);
if (((uint8_t *)p->ip6h + (ptrdiff_t)hlen) >
((uint8_t *)GET_PKT_DATA(p) + (ptrdiff_t)GET_PKT_LEN(p)))
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
+ if (p->tcph == NULL) {
+ // may happen when DecodeTCPPacket fails
+ // for instance with invalid header length
+ return NULL;
+ }
uint32_t hlen = TCP_GET_HLEN(p);
if (((uint8_t *)p->tcph + (ptrdiff_t)hlen) >
((uint8_t *)GET_PKT_DATA(p) + (ptrdiff_t)GET_PKT_LEN(p)))
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
+ if (p->udph == NULL) {
+ return NULL;
+ }
if (((uint8_t *)p->udph + (ptrdiff_t)UDP_HEADER_LEN) >
((uint8_t *)GET_PKT_DATA(p) + (ptrdiff_t)GET_PKT_LEN(p)))
{