From 6f77c0d0ca075f7264e9b7425336d08ddb9e749a Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Mon, 30 Mar 2020 09:51:27 -0400 Subject: [PATCH] detect/bsize: Ensure numeric values fit This commit ensures that the numeric values will not exceed the size of the containers used to hold them. (cherry picked from commit 5b38bc989492672277178e93b8685b9e63fe6ec8) --- src/detect-bsize.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detect-bsize.c b/src/detect-bsize.c index 2df983a028..d80ef09309 100644 --- a/src/detect-bsize.c +++ b/src/detect-bsize.c @@ -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++; } -- 2.47.2