]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/bsize: Ensure numeric values fit
authorJeff Lucovsky <jeff@lucovsky.org>
Mon, 30 Mar 2020 13:51:27 +0000 (09:51 -0400)
committerVictor Julien <victor@inliniac.net>
Tue, 31 Mar 2020 13:51:27 +0000 (15:51 +0200)
This commit ensures that the numeric values will not exceed the size of
the containers used to hold them.

src/detect-bsize.c

index 2df983a028a7377e191490d29b549a596cdc8954..d80ef09309357753597f57e9fcda84398b04eb38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Open Information Security Foundation
+/* Copyright (C) 2017-2020 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -177,7 +177,7 @@ static DetectBsizeData *DetectBsizeParse (const char *str)
     char str1[11], *p = str1;
     memset(str1, 0, sizeof(str1));
     while (*str && isdigit(*str)) {
-        if (p - str1 >= (int)sizeof(str1))
+        if (p - str1 >= ((int)sizeof(str1) - 1))
             return NULL;
         *p++ = *str++;
     }
@@ -224,7 +224,7 @@ static DetectBsizeData *DetectBsizeParse (const char *str)
         p = str2;
         memset(str2, 0, sizeof(str2));
         while (*str && isdigit(*str)) {
-            if (p - str2 >= (int)sizeof(str2))
+            if (p - str2 >= ((int)sizeof(str2) - 1))
                 return NULL;
             *p++ = *str++;
         }