detect/distance: improve value parsing and fix broken test

pull/3553/head
Victor Julien 6 years ago
parent 9cce1995ef
commit 59d526481c

@ -2773,7 +2773,7 @@ static int SigTest69TestNegatedContent(void)
static int SigTest70TestNegatedContent(void)
{
return SigTestNegativeTestContent("alert tcp any any -> any any (content:\"one\"; content:!\"fourty\"; within:52; distance:45 sid:1;)", (uint8_t *)"one four nine fourteen twentythree thirtyfive fourtysix fiftysix");
return SigTestNegativeTestContent("alert tcp any any -> any any (content:\"one\"; content:!\"fourty\"; within:52; sid:1;)", (uint8_t *)"one four nine fourteen twentythree thirtyfive fourtysix fiftysix");
}
/** \test within and distance */

@ -41,6 +41,7 @@
#include "flow-var.h"
#include "util-byte.h"
#include "util-debug.h"
#include "util-unittest.h"
#include "detect-bytejump.h"
@ -112,7 +113,11 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
cd->distance = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
cd->flags |= DETECT_CONTENT_DISTANCE_BE;
} else {
cd->distance = strtol(str, NULL, 10);
if (ByteExtractStringInt32(&cd->distance, 0, 0, str) != (int)strlen(str)) {
SCLogError(SC_ERR_INVALID_SIGNATURE,
"invalid value for distance: %s", str);
goto end;
}
}
cd->flags |= DETECT_CONTENT_DISTANCE;

Loading…
Cancel
Save