]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-bytetest: remove meaningless NULL check on data_offset
authorBoris Tonofa <b.tonofa@ideco.ru>
Mon, 30 Jun 2025 13:39:47 +0000 (16:39 +0300)
committerVictor Julien <victor@inliniac.net>
Wed, 2 Jul 2025 06:41:40 +0000 (08:41 +0200)
The condition data_offset == NULL can never be true: data_offset has
already been validated as non-NULL a few lines earlier. The guard seems
to have been intended for the offset argument, yet throughout the
codebase offset is never passed as NULL. (In the unit tests, offset is
NULL, but those tests pass the value parameter as NULL, which causes the
function to return before offset is dereferenced.)

Remove the pointless check to simplify control flow and silence
static-analysis warnings.

No functional change.

Bug 7767

src/detect-bytetest.c

index 7714e7b0ff53d62dba3217a08f9c244d2ca10ec1..e73b9bdd1b602a070c7377d8fc75d903f0146a21 100644 (file)
@@ -468,12 +468,6 @@ static DetectBytetestData *DetectBytetestParse(
         memmove(data_offset, str_ptr, end_ptr - str_ptr);
         data_offset[end_ptr-str_ptr] = '\0';
         if (data_offset[0] != '-' && isalpha((unsigned char)data_offset[0])) {
-            if (data_offset == NULL) {
-                SCLogError("byte_test supplied with "
-                           "var name for offset.  \"offset\" argument supplied to "
-                           "this function has to be non-NULL");
-                goto error;
-            }
             *offset = SCStrdup(data_offset);
             if (*offset == NULL)
                 goto error;