]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/offset: improve value parsing
authorVictor Julien <victor@inliniac.net>
Mon, 12 Nov 2018 23:33:39 +0000 (15:33 -0800)
committerVictor Julien <victor@inliniac.net>
Sun, 18 Nov 2018 14:12:51 +0000 (15:12 +0100)
src/detect-offset.c

index bed23a2d1ba261f58136b3eee9b0ea6ab1752b37..6ea9929a1277918532df8eebb5d7650b1c176fdf 100644 (file)
@@ -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",