]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2612 in SNORT/snort3 from ~BRASTULT/snort3:byte_math_cursor_fix...
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Sat, 14 Nov 2020 03:16:52 +0000 (03:16 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Sat, 14 Nov 2020 03:16:52 +0000 (03:16 +0000)
Squashed commit of the following:

commit a24ffdb10189a6022716a9e9e7f5521c1604461e
Author: Brandon Stultz <brastult@cisco.com>
Date:   Tue Nov 10 13:18:23 2020 -0500

    ips_options: don't move cursor in byte_math

src/ips_options/ips_byte_math.cc

index 9b54053392baa424306d55ed5e42fbc77cf78bdc..a65f6df8af0b4665c9bc61869e9a611b2d56d4bb 100644 (file)
@@ -213,27 +213,18 @@ IpsOption::EvalStatus ByteMathOption::eval(Cursor& c, Packet* p)
     }
 
     // do the extraction
-    int ret, bytes_read;
     uint32_t value;
 
     if (!config.string_convert_flag)
     {
-        ret = byte_extract(endian, config.bytes_to_extract, ptr, start, end, &value);
-        if (ret < 0)
+        if (byte_extract(endian, config.bytes_to_extract, ptr, start, end, &value) < 0)
             return NO_MATCH;
-
-        bytes_read = config.bytes_to_extract;
     }
     else
     {
-        ret = string_extract(config.bytes_to_extract, config.base, ptr, start, end, &value);
-        if (ret < 0)
+        if (string_extract(config.bytes_to_extract, config.base, ptr, start, end, &value) < 0)
             return NO_MATCH;
-
-        bytes_read = ret;
     }
-    /* advance cursor */
-    c.add_pos(bytes_read);
 
     if (config.bitmask_val != 0)
     {