*
* \retval A pointer to the SigMatch if found, otherwise NULL.
*/
-SigMatch *DetectByteExtractRetrieveSMVar(const char *arg, const Signature *s)
+SigMatch *DetectByteExtractRetrieveSMVar(const char *arg, int sm_list, const Signature *s)
{
for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
SigMatch *sm = s->init_data->buffers[x].head;
for (int list = 0; list < DETECT_SM_LIST_MAX; list++) {
SigMatch *sm = s->init_data->smlists[list];
while (sm != NULL) {
- if (sm->type == DETECT_BYTE_EXTRACT) {
+ // Make sure that the linked buffers ore on the same list
+ if (sm->type == DETECT_BYTE_EXTRACT && (sm_list == -1 || sm_list == list)) {
const SCDetectByteExtractData *bed = (const SCDetectByteExtractData *)sm->ctx;
if (strcmp(bed->name, arg) == 0) {
return sm;
void DetectByteExtractRegister(void);
-SigMatch *DetectByteExtractRetrieveSMVar(const char *, const Signature *);
+SigMatch *DetectByteExtractRetrieveSMVar(const char *, int sm_list, const Signature *);
int DetectByteExtractDoMatch(DetectEngineThreadCtx *, const SigMatchData *, const Signature *,
const uint8_t *, uint32_t, uint64_t *, uint8_t);
*
* \param arg The name of the variable being sought
* \param s The signature to check for the variable
+ * \param sm_list The caller's matching buffer
* \param index When found, the value of the slot within the byte vars
*
* \retval true A match for the variable was found.
* \retval false
*/
-bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
+bool DetectByteRetrieveSMVar(
+ const char *arg, const Signature *s, int sm_list, DetectByteIndexType *index)
{
- SigMatch *bed_sm = DetectByteExtractRetrieveSMVar(arg, s);
+ SigMatch *bed_sm = DetectByteExtractRetrieveSMVar(arg, sm_list, s);
if (bed_sm != NULL) {
*index = ((SCDetectByteExtractData *)bed_sm->ctx)->local_id;
return true;
}
- SigMatch *bmd_sm = DetectByteMathRetrieveSMVar(arg, s);
+ SigMatch *bmd_sm = DetectByteMathRetrieveSMVar(arg, sm_list, s);
if (bmd_sm != NULL) {
*index = ((DetectByteMathData *)bmd_sm->ctx)->local_id;
return true;
typedef uint8_t DetectByteIndexType;
-bool DetectByteRetrieveSMVar(const char *, const Signature *, DetectByteIndexType *);
+bool DetectByteRetrieveSMVar(const char *, const Signature *, int sm_list, DetectByteIndexType *);
#endif /* SURICATA_DETECT_BYTE_H */
if (nbytes != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(nbytes, s, &index)) {
+ if (!DetectByteRetrieveSMVar(nbytes, s, sm_list, &index)) {
SCLogError("Unknown byte_extract var "
"seen in byte_jump - %s",
nbytes);
if (offset != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(offset, s, &index)) {
+ if (!DetectByteRetrieveSMVar(offset, s, sm_list, &index)) {
SCLogError("Unknown byte_extract var "
"seen in byte_jump - %s",
offset);
if (nbytes != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(nbytes, s, &index)) {
+ if (!DetectByteRetrieveSMVar(nbytes, s, sm_list, &index)) {
SCLogError("unknown byte_ keyword var seen in byte_math - %s", nbytes);
goto error;
}
if (rvalue != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(rvalue, s, &index)) {
+ if (!DetectByteRetrieveSMVar(rvalue, s, sm_list, &index)) {
SCLogError("unknown byte_ keyword var seen in byte_math - %s", rvalue);
goto error;
}
*
* \retval A pointer to the SigMatch if found, otherwise NULL.
*/
-SigMatch *DetectByteMathRetrieveSMVar(const char *arg, const Signature *s)
+SigMatch *DetectByteMathRetrieveSMVar(const char *arg, int sm_list, const Signature *s)
{
for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
SigMatch *sm = s->init_data->buffers[x].head;
for (int list = 0; list < DETECT_SM_LIST_MAX; list++) {
SigMatch *sm = s->init_data->smlists[list];
while (sm != NULL) {
- if (sm->type == DETECT_BYTEMATH) {
+ // Make sure that the linked buffers ore on the same list
+ if (sm->type == DETECT_BYTEMATH && (sm_list == -1 || sm_list == list)) {
const DetectByteMathData *bmd = (const DetectByteMathData *)sm->ctx;
if (strcmp(bmd->result, arg) == 0) {
SCLogDebug("Retrieved SM for \"%s\"", arg);
void DetectBytemathRegister(void);
-SigMatch *DetectByteMathRetrieveSMVar(const char *, const Signature *);
+SigMatch *DetectByteMathRetrieveSMVar(const char *, int sm_list, const Signature *);
int DetectByteMathDoMatch(DetectEngineThreadCtx *, const DetectByteMathData *, const Signature *,
const uint8_t *, const uint32_t, uint8_t, uint64_t, uint64_t *, uint8_t);
if (value != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(value, s, &index)) {
+ if (!DetectByteRetrieveSMVar(value, s, sm_list, &index)) {
SCLogError("Unknown byte_extract var "
"seen in byte_test - %s",
value);
if (offset != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(offset, s, &index)) {
+ if (!DetectByteRetrieveSMVar(offset, s, sm_list, &index)) {
SCLogError("Unknown byte_extract var "
"seen in byte_test - %s",
offset);
if (nbytes != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(nbytes, s, &index)) {
+ if (!DetectByteRetrieveSMVar(nbytes, s, sm_list, &index)) {
SCLogError("Unknown byte_extract var "
"seen in byte_test - %s",
nbytes);
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(str, s, &index)) {
+ if (!DetectByteRetrieveSMVar(str, s, -1, &index)) {
SCLogError("unknown byte_ keyword var "
"seen in depth - %s.",
str);
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(str, s, &index)) {
+ if (!DetectByteRetrieveSMVar(str, s, -1, &index)) {
SCLogError("unknown byte_ keyword var "
"seen in distance - %s",
str);
if (bjflags & DETECT_BYTEJUMP_OFFSET_VAR) {
offset = det_ctx->byte_values[offset];
+ SCLogDebug("[BJ] using offset value %d", offset);
}
if (bjflags & DETECT_BYTEJUMP_NBYTES_VAR) {
nbytes = det_ctx->byte_values[bjd->nbytes];
+ SCLogDebug("[BJ] using nbytes value %d [index %d]", nbytes, bjd->nbytes);
} else {
nbytes = bjd->nbytes;
+ SCLogDebug("[BJ] using nbytes value %d [index n/a]", nbytes);
}
/* if we have dce enabled we will have to use the endianness
if (offset != NULL) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(offset, s, &index)) {
+ if (!DetectByteRetrieveSMVar(offset, s, -1, &index)) {
SCLogError("Unknown byte_extract var "
"seen in isdataat - %s\n",
offset);
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(str, s, &index)) {
+ if (!DetectByteRetrieveSMVar(str, s, -1, &index)) {
SCLogError("unknown byte_ keyword var "
"seen in offset - %s.",
str);
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
- if (!DetectByteRetrieveSMVar(str, s, &index)) {
+ if (!DetectByteRetrieveSMVar(str, s, -1, &index)) {
SCLogError("unknown byte_ keyword var "
"seen in within - %s",
str);
}
DetectByteIndexType idx;
- if (!DetectByteRetrieveSMVar(name, s, &idx)) {
+ if (!DetectByteRetrieveSMVar(name, s, -1, &idx)) {
luaL_error(L, "unknown byte_extract or byte_math variable: %s", name);
}