diff --git a/src/detect-offset.c b/src/detect-offset.c index bed23a2d1b..6ea9929a12 100644 --- a/src/detect-offset.c +++ b/src/detect-offset.c @@ -37,6 +37,7 @@ #include "flow-var.h" +#include "util-byte.h" #include "util-debug.h" static int DetectOffsetSetup(DetectEngineCtx *, Signature *, const char *); @@ -105,7 +106,11 @@ int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *offset cd->offset = ((DetectByteExtractData *)bed_sm->ctx)->local_id; cd->flags |= DETECT_CONTENT_OFFSET_BE; } else { - cd->offset = (uint32_t)atoi(str); + if (ByteExtractStringUint16(&cd->offset, 0, 0, str) != (int)strlen(str)) + { + SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid value for offset: %s", str); + goto end; + } if (cd->depth != 0) { if (cd->depth < cd->content_len) { SCLogDebug("depth increased to %"PRIu32" to match pattern len",