]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2460 in SNORT/snort3 from ~RUCOMBS/snort3:b4rc to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 11 Sep 2020 11:34:30 +0000 (11:34 +0000)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 11 Sep 2020 11:34:30 +0000 (11:34 +0000)
Squashed commit of the following:

commit 178c3e27da00bd22f43c0b8938a66e87420accca
Author: russ <rucombs@cisco.com>
Date:   Sat Sep 5 10:20:03 2020 -0400

    build: fix minor cppcheck warnings

commit 6fb3475f2cba53e0bb7c5da61f1116f0e2f58be9
Author: russ <rucombs@cisco.com>
Date:   Fri Sep 4 19:48:09 2020 -0400

    byte_jump: fix jump relative to extracted length w/o relative offset

    Thanks to James Manger for reporting the problem.

commit f201d1535a7cd71a574db9674bf8557a6cbeaacd
Author: russ <rucombs@cisco.com>
Date:   Fri Sep 4 19:21:03 2020 -0400

    IPS options: ensure all options use base class hash and compare methods

commit fe5c4284fd53c4d257e0f19631cb3bbddd44ed89
Author: russ <rucombs@cisco.com>
Date:   Fri Sep 4 16:15:21 2020 -0400

    snort: address fatal shutdown stability issues

    First: upon a fatal error, don't attempt to exit from other than the
    main thread to avoid hanging waiting on other threads.

    Second: don't attempt general clean up except for REG_TEST builds.  This
    is attempted only to avoid voluminous leak sanitizer dumps.  Clean exit
    if fraught with peril upon fatal and should not crash production builds.

    Third: explicilty stop file service in case the capture thread is
    running to avoid hanging on shutdown.

    TBD: eliminate unnecessary fatal conditions which should only exist from
    the main thread and only at startup.  Runtime fatals must all be
    converted to graceful shutdowns to avoid leaking external resources.
    Also need a more general scheme for managing aux threads.

commit 476a0e5d9b3b201de309a305855525b530137f36
Author: russ <rucombs@cisco.com>
Date:   Fri Sep 4 13:43:40 2020 -0400

    http_method: make available for fast pattern with first body section

commit 5a3fa3408b764b116839abe93c80ba3420977e9b
Author: russ <rucombs@cisco.com>
Date:   Tue Sep 1 15:51:54 2020 -0400

    mime: minor code cleanup

commit 1a2cb474d3fedadbe35604f85d24ac890d5bb75a
Author: russ <rucombs@cisco.com>
Date:   Tue Sep 1 15:36:25 2020 -0400

    mime: fix off-by-1 error with filename and email id capture

    Thanks to Y M <snort@outlook.com> for reporting the issue.

82 files changed:
src/ips_options/ips_ack.cc
src/ips_options/ips_asn1.cc
src/ips_options/ips_base64.cc
src/ips_options/ips_ber_data.cc
src/ips_options/ips_ber_skip.cc
src/ips_options/ips_bufferlen.cc
src/ips_options/ips_byte_extract.cc
src/ips_options/ips_byte_jump.cc
src/ips_options/ips_byte_math.cc
src/ips_options/ips_byte_test.cc
src/ips_options/ips_content.cc
src/ips_options/ips_cvs.cc
src/ips_options/ips_dsize.cc
src/ips_options/ips_file_type.cc
src/ips_options/ips_flags.cc
src/ips_options/ips_flow.cc
src/ips_options/ips_flowbits.cc
src/ips_options/ips_fragbits.cc
src/ips_options/ips_fragoffset.cc
src/ips_options/ips_hash.cc
src/ips_options/ips_icmp_id.cc
src/ips_options/ips_icmp_seq.cc
src/ips_options/ips_icode.cc
src/ips_options/ips_id.cc
src/ips_options/ips_ip_proto.cc
src/ips_options/ips_ipopts.cc
src/ips_options/ips_isdataat.cc
src/ips_options/ips_itype.cc
src/ips_options/ips_luajit.cc
src/ips_options/ips_pcre.cc
src/ips_options/ips_regex.cc
src/ips_options/ips_replace.cc
src/ips_options/ips_rpc.cc
src/ips_options/ips_sd_pattern.cc
src/ips_options/ips_seq.cc
src/ips_options/ips_so.cc
src/ips_options/ips_tos.cc
src/ips_options/ips_ttl.cc
src/ips_options/ips_window.cc
src/ips_options/test/ips_regex_test.cc
src/log/messages.cc
src/main/snort_config.cc
src/main/thread.h
src/mime/file_mime_log.cc
src/network_inspectors/appid/ips_appid_option.cc
src/service_inspectors/cip/ips_cip_attribute.cc
src/service_inspectors/cip/ips_cip_class.cc
src/service_inspectors/cip/ips_cip_connpathclass.cc
src/service_inspectors/cip/ips_cip_enipcommand.cc
src/service_inspectors/cip/ips_cip_enipreq.cc
src/service_inspectors/cip/ips_cip_eniprsp.cc
src/service_inspectors/cip/ips_cip_instance.cc
src/service_inspectors/cip/ips_cip_req.cc
src/service_inspectors/cip/ips_cip_rsp.cc
src/service_inspectors/cip/ips_cip_service.cc
src/service_inspectors/cip/ips_cip_status.cc
src/service_inspectors/dce_rpc/ips_dce_iface.cc
src/service_inspectors/dce_rpc/ips_dce_opnum.cc
src/service_inspectors/dce_rpc/ips_dce_stub_data.cc
src/service_inspectors/dnp3/ips_dnp3_data.cc
src/service_inspectors/dnp3/ips_dnp3_func.cc
src/service_inspectors/dnp3/ips_dnp3_ind.cc
src/service_inspectors/dnp3/ips_dnp3_obj.cc
src/service_inspectors/gtp/ips_gtp_info.cc
src/service_inspectors/gtp/ips_gtp_type.cc
src/service_inspectors/gtp/ips_gtp_version.cc
src/service_inspectors/http2_inspect/http2_hpack.cc
src/service_inspectors/http2_inspect/http2_hpack.h
src/service_inspectors/http_inspect/http_inspect.cc
src/service_inspectors/modbus/ips_modbus_data.cc
src/service_inspectors/modbus/ips_modbus_func.cc
src/service_inspectors/modbus/ips_modbus_unit.cc
src/service_inspectors/s7commplus/ips_s7comm_content.cc
src/service_inspectors/s7commplus/ips_s7comm_func.cc
src/service_inspectors/s7commplus/ips_s7comm_opcode.cc
src/service_inspectors/sip/ips_sip_method.cc
src/service_inspectors/sip/ips_sip_stat_code.cc
src/service_inspectors/ssl/ips_ssl_state.cc
src/service_inspectors/ssl/ips_ssl_version.cc
src/stream/ip/ip_defrag.cc
src/stream/tcp/ips_stream_reassemble.cc
src/stream/tcp/ips_stream_size.cc

index 14e3824819f4c34d7af871711796b6063dc7cf6c..fe2e950a1012bf20e8548a11e27cf8c96a016248 100644 (file)
@@ -60,21 +60,20 @@ private:
 
 uint32_t TcpAckOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool TcpAckOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(s_name, ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const TcpAckOption& rhs = (const TcpAckOption&)ips;
index 02632fa81822842ce231614f79696cbb6821f5b0..e0c04c8e9184ceef4990298e51081cbf782863b8 100644 (file)
@@ -107,26 +107,22 @@ private:
 
 uint32_t Asn1Option::hash() const
 {
-    uint32_t a,b,c;
-    const ASN1_CTXT* data = &config;
-
-    a = data->bs_overflow;
-    b = data->double_overflow;
-    c = data->print;
+    uint32_t a = config.bs_overflow;
+    uint32_t b = config.double_overflow;
+    uint32_t c = config.print;
 
     mix(a,b,c);
 
-    a += data->length;
-    b += data->max_length;
-    c += data->offset;
+    a += config.length;
+    b += config.max_length;
+    c += config.offset;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
 
-    a += data->offset_type;
+    a += config.offset_type;
+    b += IpsOption::hash();
 
     finalize(a,b,c);
-
     return c;
 }
 
index b2f5014c98bb8237f6d6a20a429ef1c4db0577fa..a42e82d0e7649e75fdcf5c65744a776ca06fd5a4 100644 (file)
@@ -78,15 +78,14 @@ private:
 
 uint32_t Base64DecodeOption::hash() const
 {
-    uint32_t a,b,c;
-
-    a = config.bytes_to_decode;
-    b = config.offset;
-    c = config.flags;
+    uint32_t a = config.bytes_to_decode;
+    uint32_t b = config.offset;
+    uint32_t c = config.flags;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
+    a += IpsOption::hash();
 
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
index fe08a1981ab1fe96b4d2117770fd1c7b8c168327..f1815ee34528ce01fcb1a12a8242a1452c56e4a9 100644 (file)
@@ -58,9 +58,9 @@ private:
 
 uint32_t BerDataOption::hash() const
 {
-    uint32_t a = type, b = 0, c = 0;
+    uint32_t a = type, b = IpsOption::hash(), c = 0;
 
-    mix_str(a,b,c,s_name);
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -68,6 +68,9 @@ uint32_t BerDataOption::hash() const
 
 bool BerDataOption::operator==(const IpsOption& ips) const
 {
+    if ( !IpsOption::operator==(ips) )
+        return false;
+
     const BerDataOption& rhs = (const BerDataOption&)ips;
 
     if ( type != rhs.type )
index 9ecf370c5bed84acca1f4a51d837ae5953e19ab7..bb1c99e941ba9675f89f36704b19f52c1495e5cb 100644 (file)
@@ -59,9 +59,9 @@ private:
 
 uint32_t BerSkipOption::hash() const
 {
-    uint32_t a = type, b = optional, c = 0;
+    uint32_t a = type, b = optional, c = IpsOption::hash();
 
-    mix_str(a,b,c,s_name);
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -69,6 +69,9 @@ uint32_t BerSkipOption::hash() const
 
 bool BerSkipOption::operator==(const IpsOption& ips) const
 {
+    if ( !IpsOption::operator==(ips) )
+        return false;
+
     const BerSkipOption& rhs = (const BerSkipOption&)ips;
 
     if ( type != rhs.type )
index 0aa3053721bba5c450d6bac1445246274008e99b..0fcf040dff68874070d03120190d9e7b17065232 100644 (file)
@@ -60,15 +60,14 @@ private:
 
 uint32_t LenOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
index 2c68e2c519e17123d8037123d7b9f919c10c4a42..e0f76cef2942a3b7732d4690ec23978a72698c28 100644 (file)
@@ -89,27 +89,25 @@ private:
 
 uint32_t ByteExtractOption::hash() const
 {
-    uint32_t a,b,c;
-    const ByteExtractData* data = &config;
-
-    a = data->bytes_to_grab;
-    b = data->offset;
-    c = data->base;
+    uint32_t a = config.bytes_to_grab;
+    uint32_t b = config.offset;
+    uint32_t c = config.base;
 
     mix(a,b,c);
 
-    a += (data->relative_flag << 24 |
-        data->data_string_convert_flag << 16 |
-        data->align << 8 |
-        data->endianness);
-    b += data->multiplier;
-    c += data->var_number;
+    a += (config.relative_flag << 24 |
+        config.data_string_convert_flag << 16 |
+        config.align << 8 |
+        config.endianness);
+    b += config.multiplier;
+    c += config.var_number;
 
     mix(a,b,c);
 
-    a += data->bitmask_val;
-    mix_str(a,b,c,get_name());
+    a += config.bitmask_val;
+    b += IpsOption::hash();
 
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
index 8cb9e87c2e59797ff3515f4223665e5466290b7c..2d28b41873b45829e6502a74a20cbd8d311ae838 100644 (file)
@@ -141,33 +141,29 @@ private:
 
 uint32_t ByteJumpOption::hash() const
 {
-    uint32_t a,b,c;
-    const ByteJumpData* data = &config;
-
-    a = data->bytes_to_grab;
-    b = data->offset;
-    c = data->base;
+    uint32_t a = config.bytes_to_grab;
+    uint32_t b = config.offset;
+    uint32_t c = config.base;
 
     mix(a,b,c);
 
-    a += (data->relative_flag << 24 |
-        data->data_string_convert_flag << 16 |
-        data->from_beginning_flag << 8 |
-        data->align_flag);
-    b += data->endianness;
-    c += data->multiplier;
+    a += (config.relative_flag << 24 |
+        config.data_string_convert_flag << 16 |
+        config.from_beginning_flag << 8 |
+        config.align_flag);
+    b += config.endianness;
+    c += config.multiplier;
 
     mix(a,b,c);
 
-    a += data->post_offset;
-    b += data->from_end_flag << 16 | (uint32_t) data->offset_var << 8 | data->post_offset_var;
-    c += data->bitmask_val;
+    a += config.post_offset;
+    b += config.from_end_flag << 16 | (uint32_t) config.offset_var << 8 | config.post_offset_var;
+    c += config.bitmask_val;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
+    a += IpsOption::hash();
 
     finalize(a,b,c);
-
     return c;
 }
 
@@ -303,15 +299,15 @@ IpsOption::EvalStatus ByteJumpOption::eval(Cursor& c, Packet* p)
     uint32_t pos;
 
     if ( bjd->from_beginning_flag )
-        pos = jump;
+        pos = 0;
 
     else if ( bjd->from_end_flag )
-        pos = c.size() + jump;
+        pos = c.size();
 
     else
-        pos = c.get_pos() + offset + payload_bytes_grabbed + jump;
+        pos = (base_ptr - start_ptr) + payload_bytes_grabbed;
 
-    pos += post_offset;
+    pos += jump + post_offset;
 
     if ( !c.set_pos(pos) )
         return NO_MATCH;
index d7137ef25ba9606cf71f2b0ee7692338247bd312..9b54053392baa424306d55ed5e42fbc77cf78bdc 100644 (file)
@@ -100,30 +100,30 @@ private:
 
 uint32_t ByteMathOption::hash() const
 {
-    uint32_t a,b,c;
-    const ByteMathData* data = &config;
+    uint32_t a = config.bytes_to_extract;
+    uint32_t b = config.rvalue;
+    uint32_t c = config.oper;
 
-    a = data->bytes_to_extract;
-    b = data->rvalue;
-    c = data->oper;
+    mix(a,b,c);
+
+    a += config.offset;
+    b += ((uint32_t) config.rvalue_var << 24 |
+        (uint32_t) config.offset_var << 16 |
+        (uint32_t) config.result_var << 8 |
+        config.endianess);
+    c += config.base;
 
     mix(a,b,c);
 
-    a += data->offset;
-    b += ((uint32_t) data->rvalue_var << 24 |
-        (uint32_t) data->offset_var << 16 |
-        (uint32_t) data->result_var << 8 |
-        data->endianess);
-    c += data->base;
+    a += config.bitmask_val;
+    b += config.relative_flag;
+    c += config.string_convert_flag;
 
     mix(a,b,c);
 
-    a += data->bitmask_val;
-    b += data->relative_flag;
-    c += data->string_convert_flag;
-    mix_str(a,b,c,get_name());
-    finalize(a,b,c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
index a4be24e807bbe88dff0945fe537b80f9e7709e17..78a3f26dc2e6e2a7ea80477394d286d85d7a596f 100644 (file)
@@ -210,30 +210,29 @@ private:
 
 uint32_t ByteTestOption::hash() const
 {
-    uint32_t a,b,c;
-    const ByteTestData* data = &config;
-
-    a = data->bytes_to_compare;
-    b = data->cmp_value;
-    c = data->opcode;
+    uint32_t a = config.bytes_to_compare;
+    uint32_t b = config.cmp_value;
+    uint32_t c = config.opcode;
 
     mix(a,b,c);
 
-    a += data->offset;
-    b += data->not_flag ? (1 << 24) : 0;
-    b += data->relative_flag ? (1 << 16) : 0;
-    b += data->data_string_convert_flag ? (1 << 8) : 0;
-    b += data->endianness;
-    c += data->base;
+    a += config.offset;
+    b += config.not_flag ? (1 << 24) : 0;
+    b += config.relative_flag ? (1 << 16) : 0;
+    b += config.data_string_convert_flag ? (1 << 8) : 0;
+    b += config.endianness;
+    c += config.base;
 
     mix(a,b,c);
 
-    a += data->cmp_value_var;
-    b += data->offset_var;
-    c += data->bitmask_val;
+    a += config.cmp_value_var;
+    b += config.offset_var;
+    c += config.bitmask_val;
+
+    mix(a,b,c);
+    a += IpsOption::hash();
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
 
     return c;
index 378e60b187d08422bdeb1f8feef3548f18175d5b..62e6a188410b572cf9b6694f57f55769b855fecb 100644 (file)
@@ -181,33 +181,31 @@ bool ContentOption::retry(Cursor& c)
 
 uint32_t ContentOption::hash() const
 {
-    const ContentData* cd = config;
-
-    uint32_t a = cd->pmd.flags;
-    uint32_t b = cd->pmd.offset;
-    uint32_t c = cd->pmd.depth;
+    uint32_t a = config->pmd.flags;
+    uint32_t b = config->pmd.offset;
+    uint32_t c = config->pmd.depth;
 
     mix(a,b,c);
 
-    a += cd->pmd.pattern_size;
-    b += cd->pmd.fp_offset;
-    c += cd->pmd.fp_length;
+    a += config->pmd.pattern_size;
+    b += config->pmd.fp_offset;
+    c += config->pmd.fp_length;
 
     mix(a,b,c);
 
-    a += cd->pmd.pm_type;
+    a += config->pmd.pm_type;
+    b += IpsOption::hash();
 
-    if ( cd->pmd.pattern_size )
-        mix_str(a, b, c, cd->pmd.pattern_buf, cd->pmd.pattern_size);
+    mix(a, b, c);
 
-    mix_str(a, b, c, get_name());
+    if ( config->pmd.pattern_size )
+        mix_str(a, b, c, config->pmd.pattern_buf, config->pmd.pattern_size);
 
-    a += cd->depth_var;
-    b += cd->offset_var;
-    c += cd->match_delta;
+    a += config->depth_var;
+    b += config->offset_var;
+    c += config->match_delta;
 
     mix(a, b, c);
-
     finalize(a, b, c);
 
     return c;
index 58af1300bb397bb594eec219c0923fd927be27f3..41f7009de15ad04e3d68764b4eaaeff2482858e5 100644 (file)
@@ -115,14 +115,11 @@ private:
 
 uint32_t CvsOption::hash() const
 {
-    uint32_t a,b,c;
-    const CvsRuleOption* data = &config;
+    uint32_t a = config.type;
+    uint32_t b = IpsOption::hash();
+    uint32_t c = 0;
 
-    a = data->type;
-    b = 0;
-    c = 0;
-
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -130,7 +127,7 @@ uint32_t CvsOption::hash() const
 
 bool CvsOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CvsOption& rhs = (const CvsOption&)ips;
index 14621adf8963b6d8e29c0a4853e2734c93613cec..5acc684c401d99e26417cb5a61e07a6d3f3def15 100644 (file)
@@ -57,22 +57,20 @@ private:
 
 uint32_t DsizeOption::hash() const
 {
-    uint32_t a,b,c;
-
-    a = config.min;
-    b = config.max;
-    c = config.op;
+    uint32_t a = config.min;
+    uint32_t b = config.max;
+    uint32_t c = config.op;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
-    finalize(a,b,c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
 bool DsizeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const DsizeOption& rhs = (const DsizeOption&)ips;
index 7797fcd5fb2c299e9e14b2259e75ded6b4af6706..ee4fd8a4c0dd54501bf4b2368c64b548912810c9 100644 (file)
@@ -64,8 +64,7 @@ FileTypeOption::FileTypeOption(const FileTypeBitSet& t) : IpsOption(s_name)
 
 uint32_t FileTypeOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
-    mix_str(a, b, c, get_name());
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
     mix_str(a, b, c, types.to_string().c_str());
     finalize(a, b, c);
     return c;
@@ -73,7 +72,7 @@ uint32_t FileTypeOption::hash() const
 
 bool FileTypeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     return types == ((const FileTypeOption&) ips).types;
index b505d217789bf32566756e865242638ba2e0ba07..e45b5741884639dc77caf5f93e0ffc2878bdb4dc 100644 (file)
@@ -81,14 +81,11 @@ private:
 
 uint32_t TcpFlagOption::hash() const
 {
-    uint32_t a,b,c;
-    const TcpFlagCheckData* data = &config;
+    uint32_t a = config.mode;
+    uint32_t b = config.tcp_flags | (config.tcp_mask << 8);
+    uint32_t c = IpsOption::hash();
 
-    a = data->mode;
-    b = data->tcp_flags | (data->tcp_mask << 8);
-    c = 0;
-
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -96,7 +93,7 @@ uint32_t TcpFlagOption::hash() const
 
 bool TcpFlagOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const TcpFlagOption& rhs = (const TcpFlagOption&)ips;
index 3268342410b548166208c915b678b71c83268699..e31fbca697d50120a7e4fd4a97e767549aeee633 100644 (file)
@@ -74,17 +74,16 @@ public:
 
 uint32_t FlowCheckOption::hash() const
 {
-    uint32_t a,b,c;
-    const FlowCheckData* data = &config;
-
-    a = data->from_server | (data->from_client << 16);
-    b = data->ignore_reassembled | (data->only_reassembled << 16);
-    c = data->stateless | (data->established << 16);
+    uint32_t a = config.from_server | (config.from_client << 16);
+    uint32_t b = config.ignore_reassembled | (config.only_reassembled << 16);
+    uint32_t c = config.stateless | (config.established << 16);
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
 
-    a += data->unestablished;
+    a += config.unestablished;
+    b += IpsOption::hash();
+
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -92,7 +91,7 @@ uint32_t FlowCheckOption::hash() const
 
 bool FlowCheckOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const FlowCheckOption& rhs = (const FlowCheckOption&)ips;
index 4f5e2264c8009ee36bee5e022b915a2ee4c7a5bc..0092dae1d1ed104f6a2507e8106939d6266a89c0 100644 (file)
@@ -172,48 +172,44 @@ FlowBitsOption::~FlowBitsOption()
 
 uint32_t FlowBitsOption::hash() const
 {
-    uint32_t a,b,c;
-    const FlowBitCheck* data = config;
-    unsigned i;
-    unsigned j = 0;
-
-    a = data->or_bits ? 1 : 0;
-    b = data->type;
-    c = 0;
+    uint32_t a = config->or_bits ? 1 : 0;
+    uint32_t b = config->type;
+    uint32_t c = IpsOption::hash();
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
 
-    for (i = 0, j = 0; i < data->ids.size(); i++, j++)
+    unsigned i;
+    unsigned j = 0;
+
+    for (i = 0, j = 0; i < config->ids.size(); i++, j++)
     {
         if (j >= 3)
         {
-            a += data->ids[i - 2];
-            b += data->ids[i - 1];
-            c += data->ids[i];
+            a += config->ids[i - 2];
+            b += config->ids[i - 1];
+            c += config->ids[i];
             mix(a,b,c);
             j -= 3;
         }
     }
     if (1 == j)
     {
-        a += data->ids[data->ids.size() - 1];
-        b += data->ids.size();
+        a += config->ids[config->ids.size() - 1];
+        b += config->ids.size();
     }
     else if (2 == j)
     {
-        a += data->ids[data->ids.size() - 2];
-        b += data->ids[data->ids.size() - 1]|data->ids.size() << 16;
+        a += config->ids[config->ids.size() - 2];
+        b += config->ids[config->ids.size() - 1]|config->ids.size() << 16;
     }
 
     finalize(a,b,c);
-
     return c;
 }
 
 bool FlowBitsOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const FlowBitsOption& rhs = (const FlowBitsOption&)ips;
index 48a147d66756691790a12791755296837a2d68ab..aeda7327905a4ab82d9a0d77583dab4d08f29d3c 100644 (file)
@@ -285,14 +285,11 @@ private:
 
 uint32_t FragBitsOption::hash() const
 {
-    uint32_t a,b,c;
-    const FragBitsData* data = &fragBitsData;
+    uint32_t a = fragBitsData.get_mode();
+    uint32_t b = fragBitsData.get_frag_bits();
+    uint32_t c = IpsOption::hash();
 
-    a = data->get_mode();
-    b = data->get_frag_bits();
-    c = 0;
-
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -300,7 +297,7 @@ uint32_t FragBitsOption::hash() const
 
 bool FragBitsOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const FragBitsOption& rhs = (const FragBitsOption&)ips;
index e9b6f3e768d69730dd73a7446ad9e213faf0718c..403f05dca7e3919a2e19b987963d3465b6c09c68 100644 (file)
@@ -56,21 +56,20 @@ private:
 
 uint32_t FragOffsetOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = (uint32_t)config.min;
+    uint32_t c = (uint32_t)config.max;
 
-    a = config.op;
-    b = (uint32_t)config.min;
-    c = (uint32_t)config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool FragOffsetOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const FragOffsetOption& rhs = (const FragOffsetOption&)ips;
index f367ba418a8be9fb309632ca3beba98b332d93af..6cf83d3692db7371bc81c0791009d4edd41204da 100644 (file)
@@ -98,20 +98,20 @@ private:
 
 uint32_t HashOption::hash() const
 {
-    uint32_t a,b,c;
-    const HashMatchData* hmd = config;
+    uint32_t a = config->negated;
+    uint32_t b = config->relative;
+    uint32_t c = size;
 
-    a = hmd->negated;
-    b = hmd->relative;
-    c = size;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,hmd->hash.c_str());
+    mix_str(a,b,c,config->hash.c_str());
 
-    a += hmd->length;
-    b += hmd->offset;
-    c += hmd->offset_var;
+    a += config->length;
+    b += config->offset;
+    c += config->offset_var;
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
index a17ad72464682d3a6acf275820775c1273afd31d..fd0412f3686c25004145b42f52ebc47d7d32ca11 100644 (file)
@@ -80,21 +80,20 @@ private:
 
 uint32_t IcmpIdOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool IcmpIdOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IcmpIdOption& rhs = (const IcmpIdOption&)ips;
index d16d372f848aa57390140f3635c210858c5c153a..9546f622baa273b77141d7ccdfb79705f1223060 100644 (file)
@@ -80,21 +80,20 @@ private:
 
 uint32_t IcmpSeqOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool IcmpSeqOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IcmpSeqOption& rhs = (const IcmpSeqOption&)ips;
index ac2f3b471408bb20da33ac623795ea690e7ec88c..176373f8d832c47affe94a3d96797ae91eb10efb 100644 (file)
@@ -57,21 +57,20 @@ private:
 
 uint32_t IcodeOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool IcodeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IcodeOption& rhs = (const IcodeOption&)ips;
index 09fcb78e5d189cb978a60cde4e1ae3de3592b698..0857718de8d5643dad7cd90ca326a173da9b3797 100644 (file)
@@ -56,21 +56,20 @@ private:
 
 uint32_t IpIdOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool IpIdOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IpIdOption& rhs = (const IpIdOption&)ips;
index ce9cbf95317bf4046e36b0507b4d8ce8b534a40a..51f916328125df286f2872cfe298fdec3e7e50a8 100644 (file)
@@ -73,14 +73,11 @@ private:
 
 uint32_t IpProtoOption::hash() const
 {
-    uint32_t a,b,c;
-    const IpProtoData* data = &config;
+    uint32_t a = to_utype(config.protocol);
+    uint32_t b = config.comparison_flag;
+    uint32_t c = IpsOption::hash();
 
-    a = to_utype(data->protocol);
-    b = data->comparison_flag;
-    c = 0;
-
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -88,7 +85,7 @@ uint32_t IpProtoOption::hash() const
 
 bool IpProtoOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IpProtoOption& rhs = (const IpProtoOption&)ips;
index c3fcd271b4d58c3ef6eab2829f9aeec28554b773..92c6866078b1b140be7e7118292d3396000052d8 100644 (file)
@@ -66,14 +66,11 @@ private:
 
 uint32_t IpOptOption::hash() const
 {
-    uint32_t a,b,c;
-    const IpOptionData* data = &config;
+    uint32_t a = (uint32_t)config.ip_option;
+    uint32_t b = config.any_flag;
+    uint32_t c = IpsOption::hash();
 
-    a = (uint32_t)data->ip_option;
-    b = data->any_flag;
-    c = 0;
-
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -81,7 +78,7 @@ uint32_t IpOptOption::hash() const
 
 bool IpOptOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IpOptOption& rhs = (const IpOptOption&)ips;
index 15b9a75530f81219c0bcf276301f5326997ee80a..5a478a52588d421af5ca9a1d3b74561f6bf38618 100644 (file)
@@ -93,23 +93,20 @@ private:
 
 uint32_t IsDataAtOption::hash() const
 {
-    uint32_t a,b,c;
-    const IsDataAtData* data = &config;
-
-    a = data->offset;
-    b = data->flags;
-    c = data->offset_var;
+    uint32_t a = config.offset;
+    uint32_t b = config.flags;
+    uint32_t c = config.offset_var;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
-    finalize(a,b,c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
 bool IsDataAtOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IsDataAtOption& rhs = (const IsDataAtOption&)ips;
index eb65fa5517a492ecf89b9661ff1437fe8bc250d1..4b7cf00fd9e842f3e3705c78d46b712d8bc19143 100644 (file)
@@ -57,22 +57,20 @@ private:
 
 uint32_t IcmpTypeOption::hash() const
 {
-    uint32_t a,b,c;
-
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
-    finalize(a,b,c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
 bool IcmpTypeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IcmpTypeOption& rhs = (const IcmpTypeOption&)ips;
index 07f66e870280e3544ddfcf7787f6166e6b569a36..dbc19e6ef5c5c0be4d2b4191863609e2d0527c3f 100644 (file)
@@ -158,8 +158,7 @@ LuaJitOption::~LuaJitOption()
 
 uint32_t LuaJitOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
-    mix_str(a,b,c,get_name());
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
     mix_str(a,b,c,config.c_str());
     finalize(a,b,c);
     return c;
index 441bf7b2fd3b41d4a595b1fb193198eb1287202f..ddced62840d1118915628bb64ecb95b0b181250a 100644 (file)
@@ -524,8 +524,9 @@ uint32_t PcreOption::hash() const
     }
 
     a += config->options;
+    b += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
index d4b7dbd41df6fa7805200c321b2b6a0ea6d2bb78..4daae47106af5fe44db8ff3e2c127b6005dfd54c 100644 (file)
@@ -125,8 +125,10 @@ uint32_t RegexOption::hash() const
     uint32_t b = config.pmd.mpse_flags;
     uint32_t c = config.pmd.pm_type;
 
+    mix(a, b, c);
+    a += IpsOption::hash();
+
     mix_str(a, b, c, config.re.c_str());
-    mix_str(a, b, c, get_name());
     finalize(a, b, c);
 
     return c;
index 46111f6ed17bcb34ba2d2a0476bfd479f6d4e7ef..9bc6b68123ba6176fd03ab2c25f50da66cc75887 100644 (file)
@@ -124,18 +124,12 @@ ReplaceOption::~ReplaceOption()
 
 uint32_t ReplaceOption::hash() const
 {
-    uint32_t a,b,c;
-
-    const char* s = repl.c_str();
-    unsigned n = repl.size();
-
-    a = 0;
-    b = n;
-    c = 0;
+    uint32_t a = IpsOption::hash();
+    uint32_t b = repl.size();
+    uint32_t c = 0;
 
     mix(a,b,c);
-    mix_str(a,b,c,s,n);
-    mix_str(a,b,c,get_name());
+    mix_str(a,b,c,repl.c_str());
     finalize(a,b,c);
 
     return c;
@@ -143,7 +137,7 @@ uint32_t ReplaceOption::hash() const
 
 bool ReplaceOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const ReplaceOption& rhs = (const ReplaceOption&)ips;
index 89b8b29855fea0e7c3c5771a534500269112a994..fb4bd4e9c4e634be98c9a2a59db9f416e1f5f243 100644 (file)
@@ -79,18 +79,16 @@ private:
 
 uint32_t RpcOption::hash() const
 {
-    uint32_t a,b,c;
-    const RpcCheckData* data = &config;
-
-    a = data->program;
-    b = data->version;
-    c = data->procedure;
+    uint32_t a = config.program;
+    uint32_t b = config.version;
+    uint32_t c = config.procedure;
 
     mix(a,b,c);
 
-    a += data->flags;
+    a += config.flags;
+    b += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -98,7 +96,7 @@ uint32_t RpcOption::hash() const
 
 bool RpcOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const RpcOption& rhs = (const RpcOption&)ips;
index 38e7a7f1a4b6be6e6335ae21875fafba470e9a7c..6b26ea894c555c38178d5b4005d265496e27aba7 100644 (file)
@@ -151,8 +151,10 @@ uint32_t SdPatternOption::hash() const
     uint32_t b = config.pmd.pm_type;
     uint32_t c = config.threshold;
 
+    mix(a, b, c);
+    a += IpsOption::hash();
+
     mix_str(a, b, c, config.pii.c_str());
-    mix_str(a, b, c, get_name());
     finalize(a, b, c);
 
     return c;
index c70e8dbfaaca0fe93f9db6d201bc7bed9f1eaf42..2a43865d8ec2d60c98bd3f2bc980a3b73aa846db 100644 (file)
@@ -57,21 +57,20 @@ private:
 
 uint32_t TcpSeqOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool TcpSeqOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const TcpSeqOption& rhs = (const TcpSeqOption&)ips;
index 3467ecb85ffa9299399bca2779546f47c9fa83ee..433d695a5431a7c11235d15f0d0a376b68d71b41 100644 (file)
@@ -80,7 +80,7 @@ SoOption::~SoOption()
 
 uint32_t SoOption::hash() const
 {
-    uint32_t a = relative_flag, b = 0, c = 0;
+    uint32_t a = relative_flag, b = IpsOption::hash(), c = 0;
     mix_str(a,b,c,soid);
     mix_str(a,b,c,so);
     finalize(a,b,c);
@@ -89,6 +89,9 @@ uint32_t SoOption::hash() const
 
 bool SoOption::operator==(const IpsOption& ips) const
 {
+    if ( !IpsOption::operator==(ips) )
+        return false;
+
     const SoOption& rhs = (const SoOption&)ips;
 
     if ( strcmp(soid, rhs.soid) )
index 075eaa813fa6546c25b1eb8f46b6a1c555af1c49..d646690ae0f664a7eaac09be42593c7fbcbe23db 100644 (file)
@@ -56,21 +56,20 @@ public:
 
 uint32_t IpTosOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool IpTosOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const IpTosOption& rhs = (const IpTosOption&)ips;
index c190aaa6e8ae9edfe2884164ef19807a3c26d95b..782430262636960b50346b0ec01409709cd41a36 100644 (file)
@@ -56,14 +56,14 @@ private:
 
 uint32_t TtlOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
     mix(a,b,c);
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
 
     return c;
@@ -71,7 +71,7 @@ uint32_t TtlOption::hash() const
 
 bool TtlOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const TtlOption& rhs = (const TtlOption&)ips;
index 8b171137748a10e91d1e04710d80a80609224b82..de7b9ce7a03cd8b4b573ca6e708f33c8528dcf40 100644 (file)
@@ -57,21 +57,20 @@ private:
 
 uint32_t TcpWinOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = config.op;
+    uint32_t b = config.min;
+    uint32_t c = config.max;
 
-    a = config.op;
-    b = config.min;
-    c = config.max;
+    mix(a,b,c);
+    a += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool TcpWinOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const TcpWinOption& rhs = (const TcpWinOption&)ips;
index 13a82e20b13223051cb3c525e69d70361ef6ca7e..a35a1b4f34c498056d294f362425d4dd84597063 100644 (file)
@@ -145,6 +145,7 @@ static IpsOption* get_option(Module* mod, const char* pat)
 
     const IpsApi* api = (const IpsApi*) ips_regex;
     IpsOption* opt = api->ctor(mod, &otn);
+    IpsOption::set_buffer("pkt_data");
 
     return opt;
 }
index e805d987fa1257e909c5ee397b266e9f62d5a8b6..18f7d94c2dd0490f302589fc01acec9bf03802ee 100644 (file)
@@ -336,6 +336,10 @@ void ErrorMessage(const char* format,...)
         fprintf(stderr,"Fatal Error, Quitting..\n");
     }
 
+    // guard against FatalError calls from non-main thread (which should not happen!)
+    if ( !in_main_thread() )
+        abort();
+
     SnortConfig::cleanup_fatal_error();
 
 #if 0
index beac61b02fe9e78fcad80aa3df95923473039e49..1cf328ac17429ec675c0b3aec67fbb6636486e3a 100644 (file)
@@ -33,6 +33,7 @@
 #include "detection/fp_create.h"
 #include "dump_config/json_config_output.h"
 #include "dump_config/text_config_output.h"
+#include "file_api/file_service.h"
 #include "filters/detection_filter.h"
 #include "filters/rate_filter.h"
 #include "filters/sfrf.h"
@@ -1010,11 +1011,11 @@ void SnortConfig::set_conf(const SnortConfig* sc)
 
 void SnortConfig::cleanup_fatal_error()
 {
-    // guard against FatalError calls from packet threads (which should not happen!)
-    // FIXIT-L should also guard against non-main non-packet threads calling FatalError
-    if ( is_packet_thread() )
-        return;
+    // FIXIT-L need a generic way to manage type other threads
+    // and preferably not start them too soon
+    FileService::close();
 
+#ifdef REG_TEST
     const SnortConfig* sc = SnortConfig::get_conf();
     if ( sc && !sc->dirty_pig )
     {
@@ -1023,5 +1024,6 @@ void SnortConfig::cleanup_fatal_error()
         IpsManager::release_plugins();
         InspectorManager::release_plugins();
     }
+#endif
 }
 
index 4705ea878e41bf66b70791dc38fd56b388d4d502..304626af32569bf4d92ccaf885b7033f69b443a5 100644 (file)
@@ -54,10 +54,12 @@ namespace snort
 {
 SO_PUBLIC unsigned get_instance_id();
 SO_PUBLIC SThreadType get_thread_type();
+
+SO_PUBLIC inline bool in_main_thread()
+{ return get_thread_type() == STHREAD_TYPE_MAIN; }
+
 SO_PUBLIC inline bool is_packet_thread()
-{
-    return get_thread_type() == STHREAD_TYPE_PACKET;
-}
+{ return get_thread_type() == STHREAD_TYPE_PACKET; }
 
 // all modules that use packet thread files should call this function to
 // get a packet thread specific path.  name should be the module name or
index fd4df4041fdd240de256920f01d25e6901dd868c..9515fb0dfc39e29598afcb4423c377f58e733aeb 100644 (file)
@@ -44,43 +44,33 @@ using namespace snort;
 /* accumulate MIME attachment filenames. The filenames are appended by commas */
 int MailLogState::log_file_name(const uint8_t* start, int length)
 {
-    uint8_t* alt_buf;
-    int alt_size;
-    uint16_t* alt_len;
-
-    int log_avail = 0;
-
     if (!start || (length <= 0))
-    {
         return -1;
-    }
 
-    alt_buf = filenames;
-    alt_size =  MAX_FILE;
-    alt_len = &(file_logged);
-    log_avail = alt_size - *alt_len;
+    uint8_t* alt_buf = filenames;
+    int alt_size =  MAX_FILE;
+    uint16_t* alt_len = &(file_logged);
+
+    int sep = (*alt_len > 0) ? 1 : 0;
+    int log_avail = alt_size - *alt_len - sep;
 
     if (!alt_buf || (log_avail <= 0))
         return -1;
 
-    if (*alt_len > 0 && ((*alt_len + 1) < alt_size))
-    {
-        alt_buf[*alt_len] = ',';
-        *alt_len = *alt_len + 1;
-    }
-
-    if (length > log_avail)
-    {
-        if (*alt_len != 0)
-            *alt_len = *alt_len - 1;
-        return -1;
-    }
+    else if (log_avail < length )
+        length = log_avail;
 
     if (length > 0)
+    {
+        if (sep)
+        {
+            alt_buf[*alt_len] = ',';
+            *alt_len = *alt_len + 1;
+        }
         memcpy_s(alt_buf + *alt_len, log_avail, start, length);
-
-    file_current = *alt_len;
-    *alt_len += length;
+        file_current = *alt_len;
+        *alt_len += length;
+    }
 
     log_flags |= MIME_FLAG_FILENAME_PRESENT;
 
@@ -90,14 +80,11 @@ int MailLogState::log_file_name(const uint8_t* start, int length)
 /* Accumulate EOL separated headers, one or more at a time */
 int MailLogState::log_email_hdrs(const uint8_t* start, int length)
 {
-    int log_avail = 0;
-    uint8_t* log_buf;
-
     if (length <= 0)
         return -1;
 
-    log_avail = log_depth - hdrs_logged;
-    log_buf = (uint8_t*)emailHdrs;
+    int log_avail = log_depth - hdrs_logged;
+    uint8_t* log_buf = (uint8_t*)emailHdrs;
 
     if (log_avail <= 0)
         return 0;
@@ -124,17 +111,12 @@ int MailLogState::log_email_hdrs(const uint8_t* start, int length)
    by comma */
 int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType type)
 {
-    uint8_t* alt_buf;
-    int alt_size;
-    uint16_t* alt_len;
-    int log_avail=0;
-    const uint8_t* tmp_eol;
-
     if (length <= 0)
         return -1;
 
-    tmp_eol = (const uint8_t*)memchr(start, ':', length);
-    if (tmp_eol == nullptr)
+    const uint8_t* tmp_eol = (const uint8_t*)memchr(start, ':', length);
+
+    if ( !tmp_eol )
         return -1;
 
     if ((tmp_eol + 1) < (start + length))
@@ -145,6 +127,10 @@ int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType t
     else
         return -1;
 
+    uint8_t* alt_buf;
+    int alt_size;
+    uint16_t* alt_len;
+
     switch (type)
     {
     case EMAIL_SENDER:
@@ -163,35 +149,31 @@ int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType t
         return -1;
     }
 
-    log_avail = alt_size - *alt_len;
+    int sep = (*alt_len > 0) ? 1 : 0;
+    int log_avail = alt_size - *alt_len - sep;
 
     if (log_avail <= 0 || !alt_buf)
         return -1;
-    else if (log_avail < length)
-        length = log_avail;
 
-    if (*alt_len > 0 && ((*alt_len + 1) < alt_size))
-    {
-        alt_buf[*alt_len] = ',';
-        *alt_len = *alt_len + 1;
-    }
-
-    if (length > log_avail)
-    {
-        if (*alt_len != 0)
-            *alt_len = *alt_len - 1;
-        return -1;
-    }
+    else if (log_avail < length )
+        length = log_avail;
 
     if (length > 0)
+    {
+        if (sep)
+        {
+            alt_buf[*alt_len] = ',';
+            *alt_len = *alt_len + 1;
+        }
         memcpy_s(alt_buf + *alt_len, log_avail, start, length);
-
-    *alt_len += length;
+        *alt_len += length;
+    }
 
     if (type == EMAIL_SENDER)
         log_flags |= MIME_FLAG_MAIL_FROM_PRESENT;
     else
         log_flags |= MIME_FLAG_RCPT_TO_PRESENT;
+
     return 0;
 }
 
index 803eaf4e1afe13981a242ab8bde4f09fdd71f338..381c00f51bf572880972f21b24e743a17e6441f5 100644 (file)
@@ -68,21 +68,17 @@ private:
 
 uint32_t AppIdIpsOption::hash() const
 {
-    uint32_t abc[3];
+    uint32_t a = appid_table.size();
+    uint32_t b = IpsOption::hash();
+    uint32_t c = 0;
 
-    abc[0] = appid_table.size();
-    abc[1] = 0;
-    abc[2] = 0;
-
-    mix(abc[0], abc[1], abc[2]);
+    mix(a, b, c);
 
     for ( auto& appid_name : appid_table )
-        mix_str(abc[0], abc[1], abc[2],
-            appid_name.c_str(), appid_name.length());
-
-    finalize(abc[0], abc[1], abc[2]);
+        mix_str(a, b, c, appid_name.c_str(), appid_name.length());
 
-    return abc[2];
+    finalize(a, b, c);
+    return c;
 }
 
 bool AppIdIpsOption::operator==(const IpsOption& ips) const
index c9ff7af1439e69e235d4c1d14aa578311cf82017..80aaf4265324c2cc98c7932829b7c0aebf6566ab 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipAttributeOption::hash() const
 {
-    uint32_t a, b, c;
+    uint32_t a = cip_attr.op;
+    uint32_t b = cip_attr.min;
+    uint32_t c = cip_attr.max;
 
-    a = cip_attr.op;
-    b = cip_attr.min;
-    c = cip_attr.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipAttributeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipAttributeOption& rhs = static_cast<const CipAttributeOption&>(ips);
index c5a1d1f1671197b50ad6498aaa4fd1f260c8b78a..db2dd2f381c5d78ac3e2c8ff3a2b539d14a96f03 100644 (file)
@@ -63,21 +63,20 @@ private:
 
 uint32_t CipClassOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = cip_class.op;
+    uint32_t b = cip_class.min;
+    uint32_t c = cip_class.max;
 
-    a = cip_class.op;
-    b = cip_class.min;
-    c = cip_class.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipClassOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipClassOption& rhs = static_cast<const CipClassOption&>(ips);
index 8f93c51593d0ebd0ed085ba33f4a19a853657921..e5aa80515264989e9c3fe1dfc06296484213dd99 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipConnpathclassOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = cip_cpc.op;
+    uint32_t b = cip_cpc.min;
+    uint32_t c = cip_cpc.max;
 
-    a = cip_cpc.op;
-    b = cip_cpc.min;
-    c = cip_cpc.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipConnpathclassOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipConnpathclassOption& rhs = static_cast<const CipConnpathclassOption&>(ips);
index 5dd433a739618e514e17c1e8a3b9dceefe385e9f..221c3793c925c29f3260a5416d3c7dfe77738d20 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipEnipCommandOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = cip_enip_cmd.op;
+    uint32_t b = cip_enip_cmd.min;
+    uint32_t c = cip_enip_cmd.max;
 
-    a = cip_enip_cmd.op;
-    b = cip_enip_cmd.min;
-    c = cip_enip_cmd.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipEnipCommandOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipEnipCommandOption& rhs = static_cast<const CipEnipCommandOption&>(ips);
index f6dc0913bc11346af5fc9d3bc0c409988c2c1af4..b444a76874873fa9fb6d743ee9beaf707610b5d5 100644 (file)
@@ -58,9 +58,9 @@ public:
 
 uint32_t CipEnipreqOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -68,7 +68,7 @@ uint32_t CipEnipreqOption::hash() const
 
 bool CipEnipreqOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus CipEnipreqOption::eval(Cursor&, Packet* p)
index d4659b0f3f04660eec29a14f030165811f626509..811b5e1c849911b109e985b0e129aa1f620d5047 100644 (file)
@@ -58,9 +58,9 @@ public:
 
 uint32_t CipEnipRspOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -68,7 +68,7 @@ uint32_t CipEnipRspOption::hash() const
 
 bool CipEnipRspOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus CipEnipRspOption::eval(Cursor&, Packet* p)
index 36dc97fe1e309d00cf5d184b0e355b7699158054..df09d4bf1323627857eca3d8b960e8ec82644d77 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipInstanceOption::hash() const
 {
-    uint32_t a, b, c;
+    uint32_t a = cip_inst.op;
+    uint32_t b = cip_inst.min;
+    uint32_t c = cip_inst.max;
 
-    a = cip_inst.op;
-    b = cip_inst.min;
-    c = cip_inst.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipInstanceOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipInstanceOption& rhs = static_cast<const CipInstanceOption&>(ips);
index 7fbea0cd36381be0a70e715b38161cfdec4a7f9d..1435be71ca3932a824752942c5bdf7b7a0d5971c 100644 (file)
@@ -58,9 +58,9 @@ public:
 
 uint32_t CipReqOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -68,7 +68,7 @@ uint32_t CipReqOption::hash() const
 
 bool CipReqOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus CipReqOption::eval(Cursor&, Packet* p)
index a2c24b00eb9613a34ce1dae421c6a9d0fb82ba3b..f3aec625c7b28dde5df1b4577fa8ca3ba3d45d20 100644 (file)
@@ -58,9 +58,9 @@ public:
 
 uint32_t CipRspOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -68,7 +68,7 @@ uint32_t CipRspOption::hash() const
 
 bool CipRspOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus CipRspOption::eval(Cursor&, Packet* p)
index 55c7c17b7eb5b9ca551058952eb5fbdec0a9c1fc..0571329baa8e2d06aad1b84e61fbfe748a775015 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipServiceOption::hash() const
 {
-    uint32_t a, b, c;
+    uint32_t a = cip_serv.op;
+    uint32_t b = cip_serv.min;
+    uint32_t c = cip_serv.max;
 
-    a = cip_serv.op;
-    b = cip_serv.min;
-    c = cip_serv.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipServiceOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipServiceOption& rhs = static_cast<const CipServiceOption&>(ips);
index 78517c215f786fef548bed0e8a85374a18f3f82b..d4ed1e9acdfb72cd7965f1b61e9733a4822175f9 100644 (file)
@@ -62,21 +62,20 @@ private:
 
 uint32_t CipStatusOption::hash() const
 {
-    uint32_t a, b, c;
+    uint32_t a = cip_status.op;
+    uint32_t b = cip_status.min;
+    uint32_t c = cip_status.max;
 
-    a = cip_status.op;
-    b = cip_status.min;
-    c = cip_status.max;
+    mix(a, b, c);
+    a += IpsOption::hash();
 
-    mix_str(a, b, c, get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool CipStatusOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const CipStatusOption& rhs = static_cast<const CipStatusOption&>(ips);
index 553fe42125779eeda1847c9324d416baaaacbf09..3e5adf5c2791e081c0b35027021c1ecd9efc91db 100644 (file)
@@ -336,7 +336,7 @@ uint32_t Dce2IfaceOption::hash() const
         (uuid.node[0] << 8) |
         (uuid.node[1]);
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
 
     a += (uuid.node[2] << 24) |
         (uuid.node[3] << 16) |
@@ -349,6 +349,7 @@ uint32_t Dce2IfaceOption::hash() const
 
     a += version.op;
     b += any_frag;
+    c += IpsOption::hash();
 
     finalize(a, b, c);
 
index 8e74d1d1961961ee3339c710645c91e626cca4fc..7fb9941e1dda20527600b1d85601c3856e9fd3c2 100644 (file)
@@ -357,7 +357,7 @@ uint32_t Dce2OpnumOption::hash() const
 {
     uint32_t a = opnum.opnum_lo, b = opnum.opnum_hi, c = opnum.mask_size;
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
 
     if (opnum.mask_size != 0)
     {
@@ -368,6 +368,7 @@ uint32_t Dce2OpnumOption::hash() const
 
         mix(a,b,c);
     }
+    a += IpsOption::hash();
 
     finalize(a, b, c);
 
@@ -376,7 +377,7 @@ uint32_t Dce2OpnumOption::hash() const
 
 bool Dce2OpnumOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const Dce2OpnumOption& rhs = (const Dce2OpnumOption&)ips;
index 522b98ccc562c70fee295452d0900c26e204cf69..15603a57040b0c5a560189d917ed0b3881e9eef0 100644 (file)
@@ -56,9 +56,10 @@ public:
 
 uint32_t Dce2StubDataOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash();
+    uint32_t b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -66,7 +67,7 @@ uint32_t Dce2StubDataOption::hash() const
 
 bool Dce2StubDataOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus Dce2StubDataOption::eval(Cursor& c, Packet* p)
index 7d331678200c18b5d68b447c2d01cf06c2b7354b..419e1bd4e1c37afd0c574f446b3eb96d96fefc92 100644 (file)
@@ -57,9 +57,9 @@ public:
 
 uint32_t Dnp3DataOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -67,7 +67,7 @@ uint32_t Dnp3DataOption::hash() const
 
 bool Dnp3DataOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus Dnp3DataOption::eval(Cursor& c, Packet* p)
index 63a368308b2abc39b0d76b09ebcd82e4c5e52c7d..50f80c33690eae12a02860f6f185a05008b662b9 100644 (file)
@@ -60,9 +60,9 @@ private:
 
 uint32_t Dnp3FuncOption::hash() const
 {
-    uint32_t a = func, b = 0, c = 0;
+    uint32_t a = func, b = IpsOption::hash(), c = 0;
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -70,7 +70,7 @@ uint32_t Dnp3FuncOption::hash() const
 
 bool Dnp3FuncOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const Dnp3FuncOption& rhs = (const Dnp3FuncOption&)ips;
index 1549eefe9e8398b279c59af404da3d736531c014..9e048491cf7f401376546641e568537eabe5cf3e 100644 (file)
@@ -60,9 +60,9 @@ private:
 
 uint32_t Dnp3IndOption::hash() const
 {
-    uint32_t a = flags, b = 0, c = 0;
+    uint32_t a = flags, b = IpsOption::hash(), c = 0;
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -70,7 +70,7 @@ uint32_t Dnp3IndOption::hash() const
 
 bool Dnp3IndOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const Dnp3IndOption& rhs = (const Dnp3IndOption&)ips;
index eee61eaf2d7e431c8e906cd4dad7539276ec482c..e1816531e2a82fa45e20afd5aca1a62bda2723b6 100644 (file)
@@ -86,9 +86,9 @@ private:
 
 uint32_t Dnp3ObjOption::hash() const
 {
-    uint32_t a = group, b = var, c = 0;
+    uint32_t a = group, b = var, c = IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -96,7 +96,7 @@ uint32_t Dnp3ObjOption::hash() const
 
 bool Dnp3ObjOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const Dnp3ObjOption& rhs = (const Dnp3ObjOption&)ips;
index 6ba0373aaa8d78b8ef03c9a4b6c65f61650e160d..cf011e7b2bb8d7e5bd8f1d8e1983bf1d77e62fae 100644 (file)
@@ -77,15 +77,16 @@ uint32_t GtpInfoOption::hash() const
     uint32_t b = types[1];
     uint32_t c = types[2];
 
-    mix_str(a, b, c, get_name());
-    finalize(a,b,c);
+    mix(a, b, c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
 bool GtpInfoOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const GtpInfoOption& rhs = (const GtpInfoOption&)ips;
index 2c2dd6864753369b9d9a37f8ce58b42e6c1e090b..98fb47fd8cdd3d9769e8a57c2e4e781e64f8827d 100644 (file)
@@ -76,15 +76,16 @@ uint32_t GtpTypeOption::hash() const
     uint32_t b = types[1].count();
     uint32_t c = types[2].count();
 
-    mix_str(a, b, c, get_name());
-    finalize(a,b,c);
+    mix(a, b, c);
+    a += IpsOption::hash();
 
+    finalize(a,b,c);
     return c;
 }
 
 bool GtpTypeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const GtpTypeOption& rhs = (const GtpTypeOption&)ips;
index eca531c30903dd9e5fdd1d3768a12a0ca969aeeb..5f20e4dee11ca5f5e5d874e5ace608d27645fac6 100644 (file)
@@ -59,9 +59,9 @@ public:
 
 uint32_t GtpVersionOption::hash() const
 {
-    uint32_t a = version, b = 0, c = 0;
+    uint32_t a = version, b = IpsOption::hash(), c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -69,7 +69,7 @@ uint32_t GtpVersionOption::hash() const
 
 bool GtpVersionOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const GtpVersionOption& rhs = (const GtpVersionOption&)ips;
index 93e82b3f98f673cfeca1ec38e1786bdfef91993d..a9698fc247b50c46bc4f4678efbb118526e998e5 100644 (file)
@@ -217,7 +217,7 @@ bool Http2HpackDecoder::decode_indexed_header(const uint8_t* encoded_header_buff
     return true;
 }
 
-bool Http2HpackDecoder::write_header_part(Field& header, const uint8_t* suffix,
+bool Http2HpackDecoder::write_header_part(const Field& header, const uint8_t* suffix,
     uint32_t suffix_length, uint8_t* decoded_header_buffer, const uint32_t decoded_header_length,
     uint32_t& bytes_written)
 {
index 09b188d3482b97c3c9dc9d29eebdbc5ddf13a986..6f3badb8dd20ca7e401a97af8708ea288e150f97 100644 (file)
@@ -51,7 +51,7 @@ public:
     const HpackTableEntry* get_hpack_table_entry(const uint8_t* encoded_header_buffer,
         const uint32_t encoded_header_length, const Http2HpackIntDecode& decode_int,
         uint32_t& bytes_consumed);
-    bool write_header_part(Field& header, const uint8_t* suffix, uint32_t suffix_length,
+    bool write_header_part(const Field& header, const uint8_t* suffix, uint32_t suffix_length,
         uint8_t* decoded_header_buffer, const uint32_t decoded_header_length,
         uint32_t& bytes_written);
     bool decode_indexed_name(const uint8_t* encoded_header_buffer,
index cc466afc671e20b788476dfd373e66732cec8b00..1967e336b790c6bd4447412dc296c9d16efd37fd 100644 (file)
@@ -270,7 +270,7 @@ bool HttpInspect::get_fp_buf(InspectionBuffer::Type ibt, Packet* p, InspectionBu
             return false;
         break;
     case InspectionBuffer::IBT_METHOD:
-        if ((get_latest_src(p) != SRC_CLIENT) || (get_latest_is(p) != IS_HEADER))
+        if ((get_latest_src(p) != SRC_CLIENT) || (get_latest_is(p) == IS_BODY))
             return false;
         break;
     case InspectionBuffer::IBT_STAT_CODE:
index 2cf071522cb39d942882aca25741dc56ed4db9be..a621ab3a572aa887b42bcb5ddfd40d3d8839f580 100644 (file)
@@ -55,9 +55,9 @@ public:
 
 uint32_t ModbusDataOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -65,7 +65,7 @@ uint32_t ModbusDataOption::hash() const
 
 bool ModbusDataOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus ModbusDataOption::eval(Cursor& c, Packet* p)
index e564c99a890c980a4107e0ef9656feda5b9bde8e..9d442af0fd6608d006d108595020cd3a46735285 100644 (file)
@@ -106,9 +106,9 @@ public:
 
 uint32_t ModbusFuncOption::hash() const
 {
-    uint32_t a = func, b = 0, c = 0;
+    uint32_t a = func, b = IpsOption::hash(), c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -116,7 +116,7 @@ uint32_t ModbusFuncOption::hash() const
 
 bool ModbusFuncOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const ModbusFuncOption& rhs = (const ModbusFuncOption&)ips;
index 076637083ce28124cb6e39d99e1a977a2dd54c81..162ecb89d69a6b5e0cda859ad710a91168764281 100644 (file)
@@ -58,9 +58,9 @@ public:
 
 uint32_t ModbusUnitOption::hash() const
 {
-    uint32_t a = unit, b = 0, c = 0;
+    uint32_t a = unit, b = IpsOption::hash(), c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -68,7 +68,7 @@ uint32_t ModbusUnitOption::hash() const
 
 bool ModbusUnitOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const ModbusUnitOption& rhs = (const ModbusUnitOption&)ips;
index c17b7c54d7f0a73e2fa6dae2ad1533d63ae29632..8c334b7fc76c804fdf15642c246798b107566b1b 100644 (file)
@@ -55,9 +55,9 @@ public:
 
 uint32_t S7commplusContentOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -65,7 +65,7 @@ uint32_t S7commplusContentOption::hash() const
 
 bool S7commplusContentOption::operator==(const IpsOption& ips) const
 {
-    return !strcmp(get_name(), ips.get_name());
+    return IpsOption::operator==(ips);
 }
 
 IpsOption::EvalStatus S7commplusContentOption::eval(Cursor& c, Packet* p)
index aaba91329eeb70a4b7726aadc1a1f0cc8527248b..e46bdcb04882ba4a566c8698738642da6d2f9d93 100644 (file)
@@ -99,9 +99,9 @@ public:
 
 uint32_t S7commplusFuncOption::hash() const
 {
-    uint32_t a = func, b = 0, c = 0;
+    uint32_t a = func, b = IpsOption::hash(), c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -109,7 +109,7 @@ uint32_t S7commplusFuncOption::hash() const
 
 bool S7commplusFuncOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const S7commplusFuncOption& rhs = (const S7commplusFuncOption&)ips;
index 48478d549cacd52cb1f99e2bea07e99328926d43..6cf523f09d9a687092584ae384e6eaa9f7bb18d4 100644 (file)
@@ -92,9 +92,9 @@ public:
 
 uint32_t S7commplusOpcodeOption::hash() const
 {
-    uint32_t a = opcode, b = 0, c = 0;
+    uint32_t a = opcode, b = IpsOption::hash(), c = 0;
 
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
     finalize(a,b,c);
 
     return c;
@@ -102,7 +102,7 @@ uint32_t S7commplusOpcodeOption::hash() const
 
 bool S7commplusOpcodeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const S7commplusOpcodeOption& rhs = (const S7commplusOpcodeOption&)ips;
index f7bad4e019bbd70c26ca5bcf9f31afc9a2394db4..dbd227355f19d22508b9a6c8751d7e2a94f7485b 100644 (file)
@@ -75,25 +75,22 @@ private:
 
 uint32_t SipMethodOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = methods.size();
+    uint32_t b = a ? methods.begin()->second : 0;
+    uint32_t c = IpsOption::hash();
 
-    a = methods.size();
-    b = a ? methods.begin()->second : 0;
-    c = 0;
-
-    mix_str(a, b, c, get_name());
+    mix(a, b, c);
 
     for ( auto& m : methods )
         mix_str(a, b, c, m.first.c_str(), m.first.size());
 
     finalize(a, b, c);
-
     return c;
 }
 
 bool SipMethodOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const SipMethodOption& rhs = (const SipMethodOption&)ips;
index 45ae386b9a8396895bc599c7b40b1d99b9dd7df1..4035bab3197a3e6b0281e982b24571c43540e3b0 100644 (file)
@@ -64,20 +64,20 @@ private:
 
 uint32_t SipStatCodeOption::hash() const
 {
-    uint32_t a = 0, b = 0, c = 0;
+    uint32_t a = IpsOption::hash(), b = 0, c = 0;
 
     unsigned n = 0;
     while ( n < SIP_NUM_STAT_CODE_MAX and ssod.stat_codes[n] ) ++n;
 
     mix_str(a, b, c, (const char*)ssod.stat_codes, n*sizeof(ssod.stat_codes[0]));
-    mix_str(a, b, c, get_name());
+    finalize(a, b, c);
 
     return c;
 }
 
 bool SipStatCodeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const SipStatCodeOption& rhs = (const SipStatCodeOption&)ips;
index 00b9c5374540ca2634b103653c60186c578fdac0..2b17fa155175ca9304efb52f3191b5c4c200d92b 100644 (file)
@@ -70,21 +70,17 @@ private:
 
 uint32_t SslStateOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = ssod.flags;
+    uint32_t b = ssod.mask;
+    uint32_t c = IpsOption::hash();
 
-    a = ssod.flags;
-    b = ssod.mask;
-    c = 0;
-
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool SslStateOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const SslStateOption& rhs = (const SslStateOption&)ips;
index 5b1026e0abce8b9a39d6a313b8c4f970afb8926f..71abd16e5b236cf19164895a1eb77c0c3a5603f4 100644 (file)
@@ -70,21 +70,17 @@ private:
 
 uint32_t SslVersionOption::hash() const
 {
-    uint32_t a,b,c;
+    uint32_t a = svod.flags;
+    uint32_t b = svod.mask;
+    uint32_t c = IpsOption::hash();
 
-    a = svod.flags;
-    b = svod.mask;
-    c = 0;
-
-    mix_str(a,b,c,get_name());
     finalize(a,b,c);
-
     return c;
 }
 
 bool SslVersionOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const SslVersionOption& rhs = (const SslVersionOption&)ips;
index dd4dbe1ccac966d56dd820d045de8475676e6678..8f508bd2ff877f992179151b7666f2bb54a1c682 100644 (file)
@@ -1655,8 +1655,7 @@ left_overlap_last:
                          * further.
                          */
                         trunc = 0;
-                        if (right)
-                            continue;
+                        continue;
                     }
 
                     if (curr_end < frag_end)
index fdb3e52626eb58ed091e96af900b0ae676aac385..64d9c4ecbf286db97dc8801b85949246a4b33851 100644 (file)
@@ -72,17 +72,16 @@ private:
 
 uint32_t ReassembleOption::hash() const
 {
-    uint32_t a,b,c;
-
-    a = srod.enable;
-    b = srod.direction;
-    c = srod.alert;
+    uint32_t a = srod.enable;
+    uint32_t b = srod.direction;
+    uint32_t c = srod.alert;
 
     mix(a,b,c);
 
     a = srod.fastpath;
+    b += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -90,7 +89,7 @@ uint32_t ReassembleOption::hash() const
 
 bool ReassembleOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const ReassembleOption& rhs = (const ReassembleOption&)ips;
index 58584a773274cabec539afb6c28baf39a04ef51e..8000ea4750fab189328bc8cf83c67253d189a128 100644 (file)
@@ -64,17 +64,16 @@ private:
 
 uint32_t SizeOption::hash() const
 {
-    uint32_t a,b,c;
-
-    a = ssod.op;
-    b = ssod.min;
-    c = ssod.max;
+    uint32_t a = ssod.op;
+    uint32_t b = ssod.min;
+    uint32_t c = ssod.max;
 
     mix(a,b,c);
 
     a = direction;
+    b += IpsOption::hash();
 
-    mix_str(a,b,c,get_name());
+    mix(a,b,c);
     finalize(a,b,c);
 
     return c;
@@ -82,7 +81,7 @@ uint32_t SizeOption::hash() const
 
 bool SizeOption::operator==(const IpsOption& ips) const
 {
-    if ( strcmp(get_name(), ips.get_name()) )
+    if ( !IpsOption::operator==(ips) )
         return false;
 
     const SizeOption& rhs = (const SizeOption&)ips;