]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1452 in SNORT/snort3 from ~RUCOMBS/snort3:int_types to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Wed, 5 Dec 2018 22:57:09 +0000 (17:57 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Wed, 5 Dec 2018 22:57:09 +0000 (17:57 -0500)
Squashed commit of the following:

commit 927335a9d770afd3f976c5d433dfbf59c358f1d3
Author: russ <rucombs@cisco.com>
Date:   Sat Dec 1 09:08:48 2018 -0500

    build: clean up additional warnings

commit 237dc040cedf560fa2e10127c5db9cf6b313fd8c
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 30 14:54:58 2018 -0500

    build: fix some int format specifiers

commit bd1b6a63ed81d99dcec9404bdf08a886d04acf48
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 30 14:22:37 2018 -0500

    build: fix some int type conversion warnings

commit 489e5ce892199bef55974bbd1b85281fd1e1c453
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 30 08:17:16 2018 -0500

    parameter: remove arbitrary one day limit on timers

commit dadfae41cc9e2cc73809688de593f93b9d4e6a20
Author: russ <rucombs@cisco.com>
Date:   Thu Nov 29 08:46:55 2018 -0500

    snort: add --help-limits to output max* values

commit 8886dbaec359e974b016d5f33e50fd75a62722ef
Author: russ <rucombs@cisco.com>
Date:   Thu Nov 29 07:50:07 2018 -0500

    parameter: add maxSZ upper bound for int sizes

commit 4d29c63de0c65315f3cfb7c30d63604366369095
Author: russ <rucombs@cisco.com>
Date:   Wed Nov 28 13:39:16 2018 -0500

    parameter: add max31, max32, and max53 for int upper bounds

commit 25c837adb622de44ea746d8081498b4a3c3e3d7a
Author: russ <rucombs@cisco.com>
Date:   Tue Nov 27 08:27:05 2018 -0500

    spelling: fix typo, disable checks on test data

commit acca70d032f3de0ca5e3ca0ef4e80dbd2199d743
Author: russ <rucombs@cisco.com>
Date:   Mon Nov 26 22:46:47 2018 -0500

    parameter: clean up some signed/unsigned mismatches

commit f0d5e1a033ccf16a57af6551f098bb43adf19fdd
Author: russ <rucombs@cisco.com>
Date:   Mon Nov 26 17:37:52 2018 -0500

    parameter: remove ineffective -1 from pcre_match_limit*

commit f52729f59324519be52a0058fbe3c104bb056783
Author: russ <rucombs@cisco.com>
Date:   Mon Nov 26 12:03:55 2018 -0500

    parameter: use bool instead of int for bools

commit c845621d7900f97da697a966b4b2fe8af9008614
Author: russ <rucombs@cisco.com>
Date:   Mon Nov 26 11:44:57 2018 -0500

    parameter: use consistent default port ranges

commit ab3be3c2121bb9a2f89f65ed3712eb5f5f68046b
Author: russ <rucombs@cisco.com>
Date:   Mon Nov 26 08:32:20 2018 -0500

    parameter: clean up upper bounds

commit 78aaf9fc08d6b05e8949426eace6a83e06f731ea
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 23 10:52:57 2018 -0500

    parameter: build out validation unit tests

commit ed4235ab439d1966e645378f97fd079672329091
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 23 09:16:35 2018 -0500

    perf_monitor: fix benign parameter errors

commit bfcbb47e5c01608532df3308cf2e684c5e06b6dc
Author: russ <rucombs@cisco.com>
Date:   Fri Nov 23 09:14:57 2018 -0500

    parameter: reorgranize for unit tests

122 files changed:
src/actions/act_reject.cc
src/codecs/ip/cd_udp.cc
src/codecs/link/cd_mpls.cc
src/connectors/file_connector/file_connector_module.cc
src/connectors/tcp_connector/tcp_connector_module.cc
src/detection/detection_engine.cc
src/detection/detection_util.cc
src/detection/fp_config.cc
src/detection/fp_config.h
src/detection/fp_create.cc
src/detection/fp_detect.cc
src/detection/fp_utils.cc
src/detection/fp_utils.h
src/detection/ips_context_data.cc
src/detection/signature.cc
src/detection/signature.h
src/detection/tag.h
src/events/event_queue.h
src/file_api/file_module.cc
src/filters/detection_filter.h
src/filters/sfrf.h
src/filters/sfthd.h
src/filters/sfthreshold.h
src/framework/module.cc
src/framework/parameter.cc
src/framework/parameter.h
src/framework/value.h
src/host_tracker/host_cache_module.cc
src/host_tracker/host_tracker_module.cc
src/ips_options/ips_asn1.cc
src/ips_options/ips_base64.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_detection_filter.cc
src/ips_options/ips_gid.cc
src/ips_options/ips_hash.cc
src/ips_options/ips_pcre.cc
src/ips_options/ips_priority.cc
src/ips_options/ips_rev.cc
src/ips_options/ips_rpc.cc
src/ips_options/ips_sd_pattern.cc
src/ips_options/ips_session.cc
src/ips_options/ips_sid.cc
src/ips_options/ips_tag.cc
src/ips_options/ips_target.cc
src/latency/latency_module.cc
src/loggers/alert_csv.cc
src/loggers/alert_fast.cc
src/loggers/alert_full.cc
src/loggers/alert_json.cc
src/loggers/alert_sf_socket.cc
src/loggers/alert_syslog.cc
src/loggers/log_hext.cc
src/loggers/log_pcap.cc
src/loggers/unified2.cc
src/main/help.cc
src/main/help.h
src/main/modules.cc
src/main/snort_config.cc
src/main/snort_config.h
src/main/snort_module.cc
src/managers/ips_manager.cc
src/managers/module_manager.cc
src/managers/mpse_manager.cc
src/memory/memory_cap.cc
src/memory/memory_config.h
src/memory/memory_module.cc
src/network_inspectors/appid/appid_config.h
src/network_inspectors/appid/appid_module.cc
src/network_inspectors/appid/appid_stats.cc
src/network_inspectors/appid/tp_appid_types.h
src/network_inspectors/binder/bind_module.cc
src/network_inspectors/packet_tracer/packet_tracer_module.cc
src/network_inspectors/perf_monitor/perf_module.cc
src/network_inspectors/perf_monitor/perf_module.h
src/network_inspectors/perf_monitor/perf_monitor.cc
src/network_inspectors/port_scan/port_scan.cc
src/network_inspectors/port_scan/ps_detect.h
src/network_inspectors/port_scan/ps_module.cc
src/network_inspectors/reputation/reputation_module.cc
src/packet_io/sfdaq_module.cc
src/packet_io/trough.cc
src/packet_io/trough.h
src/parser/cmd_line.cc
src/service_inspectors/dce_rpc/dce_co.h
src/service_inspectors/dce_rpc/dce_common.cc
src/service_inspectors/dce_rpc/dce_smb.h
src/service_inspectors/dce_rpc/dce_smb_module.cc
src/service_inspectors/dce_rpc/dce_tcp_module.cc
src/service_inspectors/dce_rpc/dce_udp_module.cc
src/service_inspectors/dnp3/ips_dnp3_obj.cc
src/service_inspectors/ftp_telnet/ftp_module.cc
src/service_inspectors/ftp_telnet/telnet_module.cc
src/service_inspectors/gtp/gtp_module.cc
src/service_inspectors/gtp/ips_gtp_version.cc
src/service_inspectors/http_inspect/http_module.cc
src/service_inspectors/http_inspect/http_module.h
src/service_inspectors/imap/imap_module.cc
src/service_inspectors/modbus/ips_modbus_unit.cc
src/service_inspectors/pop/pop_module.cc
src/service_inspectors/sip/ips_sip_stat_code.cc
src/service_inspectors/sip/sip_module.cc
src/service_inspectors/smtp/smtp_module.cc
src/service_inspectors/ssh/ssh_module.cc
src/service_inspectors/ssl/ssl_module.cc
src/sfrt/sfrt_test.cc
src/stream/base/stream_module.cc
src/stream/base/stream_module.h
src/stream/icmp/icmp_module.cc
src/stream/ip/ip_module.cc
src/stream/tcp/ips_stream_reassemble.cc
src/stream/tcp/ips_stream_size.cc
src/stream/tcp/tcp_module.cc
src/stream/udp/udp_module.cc
src/stream/user/user_module.cc
src/utils/util.cc
tools/snort2lua/config_states/config_one_int_option.cc
tools/snort2lua/config_states/config_one_string_option.cc
tools/u2spewfoo/u2spewfoo.cc

index 9a8d85251aafd3c45995c0644f8b098319e29512..c364ce8eff668078865c2413beca0d5a3af20481 100644 (file)
@@ -209,10 +209,10 @@ static const int unr[] =
 bool RejectModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("reset") )
-        flags |= rst[v.get_long()];
+        flags |= rst[v.get_uint8()];
 
     else if ( v.is("control") )
-        flags |= unr[v.get_long()];
+        flags |= unr[v.get_uint8()];
 
     else
         return false;
index 3351a0fca41637cbe057becfcd54dbf834792df5..e750061370883ff48bb5133624c797b5d44908bf 100644 (file)
@@ -101,7 +101,7 @@ public:
     {
         if ( v.is("deep_teredo_inspection") )
         {
-            sc->enable_teredo = v.get_long();  // FIXIT-L move to existing bitfield
+            sc->enable_teredo = v.get_bool();
         }
         else if ( v.is("gtp_ports") )
         {
index 3e04f6692836880c6255b06cf08559a8488211fe..757fd2efe68c19aa459ae533f9c31bd34905dc4e 100644 (file)
@@ -43,7 +43,7 @@ static const Parameter mpls_params[] =
     { "enable_mpls_overlapping_ip", Parameter::PT_BOOL, nullptr, "false",
       "enable if private network addresses overlap and must be differentiated by MPLS label(s)" },
 
-    { "max_mpls_stack_depth", Parameter::PT_INT, "-1:", "-1",
+    { "max_mpls_stack_depth", Parameter::PT_INT, "-1:255", "-1",
       "set MPLS stack depth" },
 
     { "mpls_payload_type", Parameter::PT_ENUM, "eth | ip4 | ip6", "ip4",
@@ -101,11 +101,11 @@ public:
         }
         else if ( v.is("max_mpls_stack_depth") )
         {
-            sc->mpls_stack_depth = v.get_long();
+            sc->mpls_stack_depth = v.get_int16();
         }
         else if ( v.is("mpls_payload_type") )
         {
-            sc->mpls_payload_type = v.get_long() + 1;
+            sc->mpls_payload_type = v.get_uint8() + 1;
         }
         else
             return false;
index df32877dc49943e360ef77e48de805b6f0ec8df3..6e2b32ce0259efe2b36b1706394f8cc965125db4 100644 (file)
@@ -83,10 +83,10 @@ bool FileConnectorModule::set(const char*, Value& v, SnortConfig*)
         config->name = v.get_string();
 
     else if ( v.is("format") )
-        config->text_format = ( v.get_long() == 1 );
+        config->text_format = ( v.get_uint8() == 1 );
 
     else if ( v.is("direction") )
-        switch ( v.get_long() )
+        switch ( v.get_uint8() )
         {
         case 0:
         {
index 20355ae9cff1fe1d560c19a5788ff15597ee8b6f..4da921086a2648314260eeb5c33a1eef4222a5a7 100644 (file)
@@ -83,10 +83,10 @@ bool TcpConnectorModule::set(const char*, Value& v, SnortConfig*)
         config->address = v.get_string();
 
     else if ( v.is("base_port") )
-        config->base_port = v.get_long();
+        config->base_port = v.get_uint16();
 
     else if ( v.is("setup") )
-        switch ( v.get_long() )
+        switch ( v.get_uint8() )
         {
         case 0:
         {
index 39889d91f43908d8c5b0a79f5c62d7d70720e5bf..152136304e53e6df31b928a20a47bd203d2cc389 100644 (file)
@@ -136,7 +136,7 @@ Packet* DetectionEngine::set_next_packet(Packet* parent)
     else if ( Snort::get_switcher()->get_context() )
         p->active = get_current_packet()->active;
     
-    // shutdown, so use a dummy so nullchecking is needed everywhere
+    // shutdown, so use a dummy so null checking is not needed everywhere
     else
     {
         p->active = &shutdown_active;
index 40474820e400f5803cbeda7a0486c41013950d3d..4304925b6fe1e7cea5d6c0168174d710c067ed5b 100644 (file)
@@ -84,8 +84,8 @@ void EventTrace_Log(const Packet* p, const OptTreeNode* otn, int action)
         event_id, otn->sigInfo.gid, otn->sigInfo.sid, otn->sigInfo.rev, acts);
 
     TextLog_Print(tlog,
-        "Pkt=%lu, Sec=%u.%6u, Len=%u, Cap=%u\n",
-        p->context->packet_number, p->pkth->ts.tv_sec, p->pkth->ts.tv_usec,
+        "Pkt=" STDu64 ", Sec=%lu.%6lu, Len=%u, Cap=%u\n",
+        p->context->packet_number, (long)p->pkth->ts.tv_sec, (long)p->pkth->ts.tv_usec,
         p->pkth->pktlen, p->pkth->caplen);
 
     TextLog_Print(tlog,
index 9d6c87f6ed88414d20c3edd4a37aa3a96561f349..5a285efe522d9c22012e8ec7d9b396831a2ae41b 100644 (file)
@@ -75,7 +75,7 @@ void FastPatternConfig::set_max_pattern_len(unsigned int max_len)
     max_pattern_len = max_len;
 }
 
-int FastPatternConfig::set_max(int bytes)
+unsigned FastPatternConfig::set_max(unsigned bytes)
 {
     if ( max_pattern_len and (bytes > max_pattern_len) )
     {
index 184c2d3ea48be7af04fdce09c788f6a3d5995dc9..a6985652ad360ea25cd0f57fc1360aa5169efd21 100644 (file)
@@ -116,10 +116,10 @@ public:
     void set_debug_print_rule_groups_uncompiled()
     { portlists_flags |= PL_DEBUG_PRINT_RULEGROUPS_UNCOMPILED; }
 
-    void set_search_opt(int flag)
+    void set_search_opt(bool flag)
     { search_opt = flag; }
 
-    int get_search_opt()
+    bool get_search_opt()
     { return search_opt; }
 
     bool set_search_method(const char*);
@@ -142,10 +142,7 @@ public:
     int get_num_patterns_truncated()
     { return num_patterns_truncated; }
 
-    int set_max(int bytes);
-
-    int get_max_pattern_len()
-    { return max_pattern_len; }
+    unsigned set_max(unsigned bytes);
 
 private:
     const snort::MpseApi* search_api;
@@ -155,13 +152,13 @@ private:
     bool split_any_any = false;
     bool debug_print_fast_pattern = false;
     bool debug = false;
+    bool search_opt = false;
 
     unsigned max_queue_events = 5;
     unsigned bleedover_port_limit = 1024;
+    unsigned max_pattern_len = 0;
 
-    int search_opt = 0;
     int portlists_flags = 0;
-    int max_pattern_len = 0;
     int num_patterns_truncated = 0;  // due to max_pattern_len
     int num_patterns_trimmed = 0;    // due to zero byte prefix
 };
index aedfe8f052027e21bcb582e6517e994af5b4dce8..725fae892fb9fdc03c5a5f4aec68f3845a8a8d0a 100644 (file)
@@ -64,11 +64,11 @@ static const char* s_group = "";
 static void fpDeletePMX(void* data);
 
 static int fpGetFinalPattern(
-    FastPatternConfig*, PatternMatchData*, const char*& ret_pattern, int& ret_bytes);
+    FastPatternConfig*, PatternMatchData*, const char*& ret_pattern, unsigned& ret_bytes);
 
 static void print_nfp_info(const char*, OptTreeNode*);
 static void print_fp_info(const char*, const OptTreeNode*, const PatternMatchData*,
-    const char* pattern, int pattern_length);
+    const char* pattern, unsigned pattern_length);
 
 static int finalize_detection_option_tree(SnortConfig* sc, detection_option_tree_root_t* root)
 {
@@ -404,7 +404,7 @@ static int fpFinishPortGroupRule(
         pg->add_rule();
 
     const char* pattern;
-    int pattern_length;
+    unsigned pattern_length;
 
     if (fpGetFinalPattern(fp, pmd, pattern, pattern_length) == -1)
         return -1;
@@ -755,7 +755,7 @@ static void fpFreeRuleMaps(SnortConfig* sc)
 
 static int fpGetFinalPattern(
     FastPatternConfig* fp, PatternMatchData* pmd,
-    const char*& ret_pattern, int& ret_bytes)
+    const char*& ret_pattern, unsigned& ret_bytes)
 {
     if ( !fp or !pmd )
     {
@@ -763,7 +763,7 @@ static int fpGetFinalPattern(
     }
 
     const char* pattern = pmd->pattern_buf;
-    int bytes = pmd->pattern_size;
+    unsigned bytes = pmd->pattern_size;
 
     // Don't mess with:
     //
@@ -806,10 +806,9 @@ static int fpGetFinalPattern(
          * beyond state 0 as long as the next input char is 0x00 */
         if ( fp->get_trim() )
         {
-            bytes =
-                flp_trim(pmd->pattern_buf, pmd->pattern_size, &pattern);
+            bytes = flp_trim(pmd->pattern_buf, pmd->pattern_size, &pattern);
 
-            if (bytes < (int)pmd->pattern_size)
+            if (bytes < pmd->pattern_size)
             {
                 // The pattern is all '\0' - use the whole pattern. This potentially
                 // hurts the performance boost gained by stripping leading zeros.
@@ -1637,8 +1636,9 @@ void get_pattern_info(const PatternMatchData* pmd,
     opts += " )";
 }
 
-static void print_fp_info(const char* group, const OptTreeNode* otn, const PatternMatchData* pmd,
-    const char* pattern, int pattern_length)
+static void print_fp_info(
+    const char* group, const OptTreeNode* otn, const PatternMatchData* pmd,
+    const char* pattern, unsigned pattern_length)
 {
     std::string hex, txt, opts;
 
index b89b1fc364c18c38ffbb4a29a60f50ee7fce6ae7..b1b867bf2497260cbae18470eb777c6094023a8e 100644 (file)
@@ -624,7 +624,7 @@ static inline int fpFinalSelectEvent(OtnxMatchData* o, Packet* p)
     int j;
     int k;
     const OptTreeNode* otn;
-    int tcnt = 0;
+    unsigned tcnt = 0;
     EventQueueConfig* eq = SnortConfig::get_conf()->event_queue_config;
     RuleTreeNode* rtn;
 
index 9df8a2972c37d7d4f358af7910fe061375e8df10..dc9609e3ce84b891be466f83eb89f89e33e5a4c6 100644 (file)
@@ -145,10 +145,10 @@ bool is_fast_pattern_only(OptFpList* ofl)
   *   length - of trimmed pattern
   *   buff - ptr to new beginning of trimmed buffer
   */
-int flp_trim(const char* p, int plen, const char** buff)
+unsigned flp_trim(const char* p, unsigned plen, const char** buff)
 {
-    int i;
-    int size = 0;
+    unsigned i;
+    unsigned size = 0;
 
     if ( !p )
         return 0;
@@ -222,7 +222,7 @@ struct FpSelector
 {
     CursorActionType cat;
     PatternMatchData* pmd;
-    int size;
+    unsigned size;
 
     FpSelector(CursorActionType, PatternMatchData*);
 
index 3d4f9d6a310da7ccc4d9e0593fc7115f0e63daf3..d11e40df3352017cc8be189f3ad02a5a77cf72a0 100644 (file)
@@ -32,7 +32,7 @@ struct PatternMatchData* get_pmd(OptFpList*, SnortProtocolId, snort::RuleDirecti
 bool is_fast_pattern_only(OptFpList*);
 void validate_fast_pattern(OptTreeNode*);
 
-int flp_trim(const char* p, int plen, const char** buff);
+unsigned flp_trim(const char* p, unsigned plen, const char** buff);
 bool set_fp_content(OptTreeNode*);
 
 std::vector <PatternMatchData*> get_fp_content(
index 230619b585c6f6edb12f6e4546ec2e609ff1a278..d460770f623c900f84387cc5ca39f61946e47412 100644 (file)
@@ -43,7 +43,7 @@ static unsigned max_id = IpsContext::max_ips_id;
 unsigned IpsContextData::get_ips_id()
 { 
     ++ips_id;
-    assert( ips_id < max_id );
+    assert(ips_id < max_id);
     return ips_id; 
 }
 
@@ -64,9 +64,9 @@ TEST_CASE("IpsContextData id", "[IpsContextData]")
 
     auto id1 = IpsContextData::get_ips_id();
     auto id2 = IpsContextData::get_ips_id();
-    CHECK(id1 != id2);
 
-    CHECK(max_id > id2 );
+    CHECK(id1 != id2);
+    CHECK(max_id > id2);
 }
 
 #endif
index aed4fdb5e46617ee1f37c96eb4b5f7452a50f21f..2d4ee53acf755d84ad6ebcc74bade27f3b5dc7bb 100644 (file)
@@ -102,7 +102,7 @@ void AddReference(
 /************************ Class/Priority Implementation ***********************/
 
 void AddClassification(
-    SnortConfig* sc, const char* type, const char* name, int priority)
+    SnortConfig* sc, const char* type, const char* name, unsigned priority)
 {
     int max_id = 0;
     ClassType* current = sc->classifications;
index 8179e27d8a22afd309dd385932588f63e4b2a348..50dff7ed6a97a24fef59be9944b73a4a819daf2a 100644 (file)
@@ -60,15 +60,15 @@ void AddReference(snort::SnortConfig*, ReferenceNode**, const char*, const char*
 struct ClassType
 {
     // FIXIT-L type and name are backwards (name -> text, type -> name)
-    char* type;      /* classification type */
-    int id;          /* classification id */
-    char* name;      /* "pretty" classification name */
-    int priority;    /* priority */
+    char* type;
+    int id;
+    char* name;  // "pretty" name
+    unsigned priority;
     ClassType* next;
 };
 
 /* NOTE:  These methods can only be used during parse time */
-void AddClassification(snort::SnortConfig*, const char* type, const char* name, int priority);
+void AddClassification(snort::SnortConfig*, const char* type, const char* name, unsigned priority);
 
 ClassType* ClassTypeLookupByType(snort::SnortConfig*, const char*);
 
index 2a935cae473163b742656b883b44d86df3b1bf16..983d68a34da2e0cc43bb0f76b7ce5ee2ff9f22d5 100644 (file)
@@ -54,11 +54,12 @@ struct Event;
 struct TagData
 {
     int tag_type;       /* tag type (session/host) */
-    int tag_seconds;    /* number of "seconds" units to tag for */
-    int tag_packets;    /* number of "packets" units to tag for */
-    int tag_bytes;      /* number of "type" units to tag for */
     int tag_metric;     /* (packets | seconds | bytes) units */
     int tag_direction;  /* source or dest, used for host tagging */
+
+    uint32_t tag_seconds;    /* number of "seconds" units to tag for */
+    uint32_t tag_packets;    /* number of "packets" units to tag for */
+    uint32_t tag_bytes;      /* number of "type" units to tag for */
 };
 
 void InitTag();
index c0e3f1dfa178458b4ba54f35dee69037cf219d07..28a2dc4c52e2ddd85f98447ce5b284ad0090c8d9 100644 (file)
@@ -28,8 +28,8 @@
 
 struct EventQueueConfig
 {
-    int max_events;
-    int log_events;
+    unsigned max_events;
+    unsigned log_events;
     int order;
     int process_all_events;
 };
index 6828f2b1a4a3cd523d1b7462d43c09504c8c6fa7..f35d481bf2736d02dcaf099e63bd0436db481c2e 100644 (file)
@@ -43,7 +43,7 @@ static const Parameter file_magic_params[] =
     { "content", Parameter::PT_STRING, nullptr, nullptr,
       "file magic content" },
 
-    { "offset", Parameter::PT_INT, "0:", "0",
+    { "offset", Parameter::PT_INT, "0:max32", "0",
       "file magic offset" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -51,7 +51,7 @@ static const Parameter file_magic_params[] =
 
 static const Parameter file_rule_params[] =
 {
-    { "rev", Parameter::PT_INT, "0:", "0",
+    { "rev", Parameter::PT_INT, "0:max32", "0",
       "rule revision" },
 
     { "msg", Parameter::PT_STRING, nullptr, nullptr,
@@ -60,7 +60,7 @@ static const Parameter file_rule_params[] =
     { "type", Parameter::PT_STRING, nullptr, nullptr,
       "file type name" },
 
-    { "id", Parameter::PT_INT, "0:", "0",
+    { "id", Parameter::PT_INT, "0:max32", "0",
       "file type id" },
 
     { "category", Parameter::PT_STRING, nullptr, nullptr,
@@ -83,7 +83,7 @@ static const Parameter file_when_params[] =
 {
     // FIXIT-M when.policy_id should be an arbitrary string auto converted
     // into index for binder matching and lookups
-    { "file_type_id", Parameter::PT_INT, "0:", "0",
+    { "file_type_id", Parameter::PT_INT, "0:max32", "0",
       "unique ID for file type in file magic rule" },
 
     { "sha256", Parameter::PT_STRING, nullptr, nullptr,
@@ -122,34 +122,34 @@ static const Parameter file_policy_rule_params[] =
 
 static const Parameter file_id_params[] =
 {
-    { "type_depth", Parameter::PT_INT, "0:", "1460",
+    { "type_depth", Parameter::PT_INT, "0:max53", "1460",
       "stop type ID at this point" },
 
-    { "signature_depth", Parameter::PT_INT, "0:", "10485760",
+    { "signature_depth", Parameter::PT_INT, "0:max53", "10485760",
       "stop signature at this point" },
 
-    { "block_timeout", Parameter::PT_INT, "0:", "86400",
+    { "block_timeout", Parameter::PT_INT, "0:max31", "86400",
       "stop blocking after this many seconds" },
 
-    { "lookup_timeout", Parameter::PT_INT, "0:", "2",
+    { "lookup_timeout", Parameter::PT_INT, "0:max31", "2",
       "give up on lookup after this many seconds" },
 
     { "block_timeout_lookup", Parameter::PT_BOOL, nullptr, "false",
       "block if lookup times out" },
 
-    { "capture_memcap", Parameter::PT_INT, "0:", "100",
+    { "capture_memcap", Parameter::PT_INT, "0:max53", "100",
       "memcap for file capture in megabytes" },
 
-    { "capture_max_size", Parameter::PT_INT, "0:", "1048576",
+    { "capture_max_size", Parameter::PT_INT, "0:max53", "1048576",
       "stop file capture beyond this point" },
 
-    { "capture_min_size", Parameter::PT_INT, "0:", "0",
+    { "capture_min_size", Parameter::PT_INT, "0:max53", "0",
       "stop file capture if file size less than this" },
 
-    { "capture_block_size", Parameter::PT_INT, "8:", "32768",
+    { "capture_block_size", Parameter::PT_INT, "8:max53", "32768",
       "file capture block size in bytes" },
 
-    { "max_files_cached", Parameter::PT_INT, "8:", "65536",
+    { "max_files_cached", Parameter::PT_INT, "8:max53", "65536",
       "maximal number of files cached in memory" },
 
     { "enable_type", Parameter::PT_BOOL, nullptr, "true",
@@ -161,7 +161,7 @@ static const Parameter file_id_params[] =
     { "enable_capture", Parameter::PT_BOOL, nullptr, "false",
       "enable file capture" },
 
-    { "show_data_depth", Parameter::PT_INT, "0:", "100",
+    { "show_data_depth", Parameter::PT_INT, "0:max53", "100",
       "print this many octets" },
 
     { "file_rules", Parameter::PT_LIST, file_rule_params, nullptr,
@@ -179,7 +179,7 @@ static const Parameter file_id_params[] =
     { "trace_stream", Parameter::PT_BOOL, nullptr, "false",
       "enable runtime dump of file data" },
 
-    { "verdict_delay", Parameter::PT_INT, "0:", "0",
+    { "verdict_delay", Parameter::PT_INT, "0:max53", "0",
       "number of queries to return final verdict" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -221,34 +221,34 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
     FilePolicy& fp = fc->get_file_policy();
 
     if ( v.is("type_depth") )
-        fc->file_type_depth = v.get_long();
+        fc->file_type_depth = v.get_int64();
 
     else if ( v.is("signature_depth") )
-        fc->file_signature_depth = v.get_long();
+        fc->file_signature_depth = v.get_int64();
 
     else if ( v.is("block_timeout") )
-        fc->file_block_timeout = v.get_long();
+        fc->file_block_timeout = v.get_int64();
 
     else if ( v.is("lookup_timeout") )
-        fc->file_lookup_timeout = v.get_long();
+        fc->file_lookup_timeout = v.get_int64();
 
     else if ( v.is("block_timeout_lookup") )
         fc->block_timeout_lookup = v.get_bool();
 
     else if ( v.is("capture_memcap") )
-        fc->capture_memcap = v.get_long();
+        fc->capture_memcap = v.get_int64();
 
     else if ( v.is("capture_max_size") )
-        fc->capture_max_size = v.get_long();
+        fc->capture_max_size = v.get_int64();
 
     else if ( v.is("capture_min_size") )
-        fc->capture_min_size = v.get_long();
+        fc->capture_min_size = v.get_int64();
 
     else if ( v.is("capture_block_size") )
-        fc->capture_block_size = v.get_long();
+        fc->capture_block_size = v.get_int64();
 
     else if ( v.is("max_files_cached") )
-        fc->max_files_cached = v.get_long();
+        fc->max_files_cached = v.get_int64();
 
     else if ( v.is("enable_type") )
     {
@@ -277,7 +277,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         }
     }
     else if ( v.is("show_data_depth") )
-        fc->show_data_depth = v.get_long();
+        fc->show_data_depth = v.get_int64();
 
     else if ( v.is("trace_type") )
         fc->trace_type = v.get_bool();
@@ -290,7 +290,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
 
     else if ( v.is("verdict_delay") )
     {
-        fc->verdict_delay = v.get_long();
+        fc->verdict_delay = v.get_int64();
         fp.set_verdict_delay(fc->verdict_delay);
     }
 
@@ -298,7 +298,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         return true;
 
     else if ( v.is("rev") )
-        rule.rev = v.get_long();
+        rule.rev = v.get_uint32();
 
     else if ( v.is("msg") )
         rule.message = v.get_string();
@@ -307,7 +307,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         rule.type = v.get_string();
 
     else if ( v.is("id") )
-        rule.id = v.get_long();
+        rule.id = v.get_uint32();
 
     else if ( v.is("category") )
         rule.category = v.get_string();
@@ -332,7 +332,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         magic.content_str = v.get_string();
 
     else if ( v.is("offset") )
-        magic.offset = v.get_long();
+        magic.offset = v.get_uint32();
 
     else if ( v.is("file_policy") )
         return true;
@@ -341,7 +341,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         return true;
 
     else if ( v.is("file_type_id") )
-        file_rule.when.type_id = v.get_long();
+        file_rule.when.type_id = v.get_uint32();
 
     else if ( v.is("sha256") )
         file_rule.when.sha256 = v.get_string();
@@ -350,7 +350,7 @@ bool FileIdModule::set(const char*, Value& v, SnortConfig*)
         return true;
 
     else if ( v.is("verdict") )
-        file_rule.use.verdict = (FileVerdict)v.get_long();
+        file_rule.use.verdict = (FileVerdict)v.get_uint8();
 
     else if ( v.is("enable_file_type") )
         file_rule.use.type_enabled = v.get_bool();
index b07347daa80afff83d4eaa9432eaacc85fdb535f..f653048108e098eae3722b05442173648aeceab6 100644 (file)
@@ -36,8 +36,8 @@ struct SfIp;
 
 struct DetectionFilterConfig
 {
+    unsigned memcap;
     int count;
-    int memcap;
     int enabled;
 };
 
index 444d132851b49ba6f90cf6dbdd706b262b2b7607..09b00de76dc8bbf4659cd2c5e1242b5adb07b386 100644 (file)
@@ -139,14 +139,9 @@ struct RateFilterConfig
      */
     struct snort::GHash* genHash [SFRF_MAX_GENID];
 
-    // Number of DOS thresholds added.
-    int count;
-
-    // count of no revert DOS thresholds
+    unsigned memcap;
     unsigned noRevertCount;
-
-    int memcap;
-
+    int count;
     int internal_event_mask;
 };
 
index 1f9b5d29c51911442e195e8c1c949dc5246930c1..20f6d8fffdc3c16f81f168518859036dbea6b031 100644 (file)
@@ -162,11 +162,13 @@ struct THDX_STRUCT
 {
     unsigned gen_id;
     unsigned sig_id;
+    unsigned seconds;
+
     int type;
+    int count;
     int tracking;
     int priority;
-    int count;
-    unsigned int seconds;
+
     sfip_var_t* ip_address;
 };
 
index 75dfffe456e051d6afa0848a85085630f3be3180..cea7e3910a12a8740c1d1e891cf90bcdf76475db 100644 (file)
@@ -30,9 +30,9 @@ struct ThresholdObjects;
 
 struct ThresholdConfig
 {
-    int memcap;
-    int enabled;
     ThresholdObjects* thd_objs;
+    unsigned memcap;
+    int enabled;
 };
 
 ThresholdConfig* ThresholdConfigNew();
index c2cf7cdf0b8c1e414c2b9979a80302b169645269..bcf1a6ffa5205e2c4f7f4855577ae8242682193f 100644 (file)
@@ -27,7 +27,7 @@ using namespace snort;
 
 static const Parameter defaults[] =
 {
-    { "trace", Parameter::PT_INT, nullptr, nullptr,
+    { "trace", Parameter::PT_INT, "0:max53", nullptr,
       "mask for enabling debug traces in module" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -79,7 +79,7 @@ bool Module::set(const char*, Value& v, SnortConfig*)
     if ( v.is("trace") )
     {
         if ( trace )
-            *trace = v.get_long();
+            *trace = v.get_uint64();
     }
     else
         return false;
index ccdc02e7b13e4ea519af614252668d03711bb378..e42c66b743b7d6d5c79534ac3d5d46f454aa7bc4 100644 (file)
 
 #include "value.h"
 
+#ifdef UNIT_TEST
+#include "catch/snort_catch.h"
+#endif
+
 using namespace snort;
 using namespace std;
 
+//--------------------------------------------------------------------------
+// helpers
+//--------------------------------------------------------------------------
+
+static bool is_sep(char c)
+{ return !c || c == '|' || isspace(c); }
+
+static const char* find(const char* r, const char* s)
+{
+    size_t n = strlen(s);
+
+    if ( !n )
+        return nullptr;
+
+    const char* t = strstr(r, s);
+
+    while ( t )
+    {
+        if ( (t == r || is_sep(t[-1])) && is_sep(t[n]) )
+            return t;
+
+        t = strstr(t+n, s);
+    }
+    return nullptr;
+}
+
+static unsigned get_index(const char* r, const char* t)
+{
+    unsigned idx = 0;
+    const char* p = strchr(r, '|');
+
+    while ( p && p < t )
+    {
+        ++idx;
+        p = strchr(p+1, '|');
+    }
+    return idx;
+}
+
+#define delim " \t\n"
+
+static size_t split(const string& txt, vector<string>& strs)
+{
+    size_t last = txt.find_first_not_of(delim);
+    size_t pos = txt.find_first_of(delim, last);
+    strs.clear();
+
+    while ( pos != string::npos )
+    {
+        if ( last != pos )
+            strs.emplace_back(txt.substr(last, pos - last));
+
+        last = txt.find_first_not_of(delim, pos + 1);
+        pos = txt.find_first_of(delim, last);
+    }
+
+    // add the last one
+    if ( last != string::npos )
+        strs.emplace_back(txt.substr(last, min(pos, txt.size()) - last));
+
+    return strs.size();
+}
+
+static int64_t get_int(const char* r)
+{
+    if ( *r == 'm' )
+    {
+        if ( !strncmp(r, "maxSZ", 5) )
+            r = (sizeof(size_t) == 4) ? "max32" : "max53";
+
+        if ( !strncmp(r, "max31", 5) )
+            return 2147483647;
+
+        if ( !strncmp(r, "max32", 5) )
+            return 4294967295;
+
+        if ( !strncmp(r, "max53", 5) )
+            return 9007199254740992;
+    }
+    return (int64_t)strtod(r, nullptr);
+}
+
+//--------------------------------------------------------------------------
+// validation methods
+//--------------------------------------------------------------------------
+
 static bool valid_bool(Value& v, const char*)
 {
     return v.get_type() == Value::VT_BOOL;
@@ -47,31 +137,34 @@ static bool valid_int(Value& v, const char* r)
     if ( v.get_type() != Value::VT_NUM )
         return false;
 
-    if ( v.get_real() != v.get_long() )
+    if ( v.get_real() != v.get_int64() )
         return false;
 
     if ( !r )
         return true;
 
-    long d = v.get_long();
+    int64_t d = v.get_int64();
 
     // require no leading or trailing whitespace
     // and either # | #: | :# | #:#
     // where # is a valid pos or neg dec, hex, or octal number
 
+    const char* t = strchr(r, ':');
+
     if ( *r != ':' )
     {
-        long low = strtol(r, nullptr, 0);
+        int64_t low = get_int(r);
 
         if ( d < low )
             return false;
-    }
 
-    const char* t = strchr(r, ':');
+        if ( !t )
+            return d == low;
+    }
 
-    if ( t && *++t )
+    if ( t and *++t )
     {
-        long hi = strtol(t, nullptr, 0);
+        int64_t hi = get_int(t);
 
         if ( d > hi )
             return false;
@@ -108,15 +201,18 @@ static bool valid_real(Value& v, const char* r)
     // and either # | #: | :# | #:#
     // where # is a valid pos or neg dec, hex, or octal number
 
+    const char* t = strchr(r, ':');
+
     if ( *r != ':' )
     {
         double low = strtod(r, nullptr);
 
         if ( d < low )
             return false;
-    }
 
-    const char* t = strchr(r, ':');
+        if ( !t )
+            return d == low;
+    }
 
     if ( t && *++t )
     {
@@ -136,37 +232,15 @@ static bool valid_string(Value& v, const char* r)
     if ( r && !strcmp(r, "(optional)") )
         return true;
 
-    unsigned len = strlen(v.get_string());
+    size_t len = strlen(v.get_string());
 
     if ( !r )
         return len > 0;
 
-    unsigned max = strtol(r, nullptr, 0);
+    size_t max = strtoul(r, nullptr, 0);
     return len <= max;
 }
 
-static bool is_sep(char c)
-{ return !c || c == '|' || isspace(c); }
-
-static const char* find(const char* r, const char* s)
-{
-    unsigned n = strlen(s);
-
-    if ( !n )
-        return nullptr;
-
-    const char* t = strstr(r, s);
-
-    while ( t )
-    {
-        if ( (t == r || is_sep(t[-1])) && is_sep(t[n]) )
-            return t;
-
-        t = strstr(t+n, s);
-    }
-    return nullptr;
-}
-
 static bool valid_select(Value& v, const char* r)
 {
     if ( v.get_type() != Value::VT_STR )
@@ -184,19 +258,6 @@ static bool valid_select(Value& v, const char* r)
     return true;
 }
 
-static unsigned get_index(const char* r, const char* t)
-{
-    unsigned idx = 0;
-    const char* p = strchr(r, '|');
-
-    while ( p && p < t )
-    {
-        ++idx;
-        p = strchr(p+1, '|');
-    }
-    return idx;
-}
-
 static bool valid_enum(Value& v, const char* r)
 {
     if ( v.get_type() != Value::VT_STR )
@@ -217,30 +278,6 @@ static bool valid_enum(Value& v, const char* r)
     return true;
 }
 
-#define delim " \t\n"
-
-static unsigned split(const string& txt, vector<string>& strs)
-{
-    size_t last = txt.find_first_not_of(delim);
-    size_t pos = txt.find_first_of(delim, last);
-    strs.clear();
-
-    while ( pos != string::npos )
-    {
-        if ( last != pos )
-            strs.emplace_back(txt.substr(last, pos - last));
-
-        last = txt.find_first_not_of(delim, pos + 1);
-        pos = txt.find_first_of(delim, last);
-    }
-
-    // add the last one
-    if ( last != string::npos )
-        strs.emplace_back(txt.substr(last, min(pos, txt.size()) - last));
-
-    return strs.size();
-}
-
 static bool valid_multi(Value& v, const char* r)
 {
     if ( v.get_type() != Value::VT_STR )
@@ -253,7 +290,7 @@ static bool valid_multi(Value& v, const char* r)
     vector<string> list;
     split(s, list);
 
-    unsigned long long mask = 0;
+    uint64_t mask = 0;
 
     for ( const auto& p : list )
     {
@@ -261,7 +298,7 @@ static bool valid_multi(Value& v, const char* r)
         if ( !t )
             return false;
 
-        unsigned idx = get_index(r, t);
+        uint64_t idx = get_index(r, t);
 
         if ( idx < Value::mask_bits )
             mask |= (1ULL << idx);
@@ -333,7 +370,7 @@ static bool valid_bit_list(Value& v, const char* r)
     string pl = v.get_string();
     string bs;
 
-    int max = r ? strtol(r, nullptr, 0) : 0;
+    size_t max = r ? strtoul(r, nullptr, 0) : 0;
     assert(max > 0);
 
     if ( pl == "any" )
@@ -350,7 +387,7 @@ static bool valid_bit_list(Value& v, const char* r)
 
     while ( ss >> bit )
     {
-        if ( bit < 0 || bit > max )
+        if ( bit < 0 || (size_t)bit > max )
             return false;
 
         bs[bit] = '1';
@@ -362,6 +399,10 @@ static bool valid_bit_list(Value& v, const char* r)
     return true;
 }
 
+//--------------------------------------------------------------------------
+// Parameter methods
+//--------------------------------------------------------------------------
+
 bool Parameter::validate(Value& v) const
 {
     switch ( type )
@@ -504,3 +545,166 @@ int Parameter::index(const char* r, const char* s)
     return (int)idx;
 }
 
+//--------------------------------------------------------------------------
+// valid_* tests
+// we only test validation here
+// side effects applied to value are tested elsewhere
+//--------------------------------------------------------------------------
+
+#ifdef UNIT_TEST
+TEST_CASE("bool", "[Parameter]")
+{
+    Value v(true);
+    CHECK(valid_bool(v, nullptr));
+}
+
+struct
+{
+    bool expected;
+    bool (*validate)(Value&, const char*);
+    double value;
+    const char* range;
+}
+num_tests[] =
+{
+// __STRDUMP_DISABLE__
+    { true, valid_int, 0, nullptr },
+    { true, valid_int, 0, "" },
+    { true, valid_int, 0, "0" },
+    { true, valid_int, 0, "0:" },
+    { true, valid_int, 0, ":0" },
+    { true, valid_int, 0, ":1" },
+    { true, valid_int, 0, "-1:1" },
+    { true, valid_int, 0, "-1:" },
+
+    { false, valid_int, 1, "0" },
+    { true, valid_int, 1, "0:" },
+    { false, valid_int, 1, ":0" },
+
+    { true, valid_int, -10, "-11:-9" },
+    { true, valid_int, 10, "9:11" },
+    { true, valid_int, 10, "0xA:11" },
+
+    { true, valid_interval, 0, nullptr },
+
+    { true, valid_real, 0, nullptr },
+    { true, valid_real, 0, "" },
+    { true, valid_real, 0, "0.0" },
+    { true, valid_real, 0, "0:" },
+    { true, valid_real, 0, ":0" },
+    { true, valid_real, 0, ":0.9" },
+    { true, valid_real, 0, "-0.9:0.9" },
+    { true, valid_real, 0, "-0.9:" },
+
+    { false, valid_real, 1, "0.9" },
+    { true, valid_real, 1, "0.9:" },
+    { false, valid_real, 1, ":0.9" },
+
+    { true, valid_real, -10, "-11.1:-9.9" },
+    { true, valid_real, 10, "9.9:11.1" },
+    { false, valid_real, 10, "011:11" },
+    { true, valid_real, 10, "0xA:11" },
+
+    { false, nullptr, 0, nullptr }
+// __STRDUMP_ENABLE__
+};
+
+TEST_CASE("num", "[Parameter]")
+{
+    auto test = num_tests;
+
+    while ( test->validate )
+    {
+        Value v(test->value);
+        bool result = test->validate(v, test->range);
+        CHECK(result == test->expected);
+        ++test;
+    }
+}
+
+struct
+{
+    bool expected;
+    bool (*validate)(Value&, const char*);
+    const char* value;
+    const char* range;
+}
+string_tests[] =
+{
+// __STRDUMP_DISABLE__
+    { true, valid_string, "green", "(optional)" },
+    { true, valid_string, "green", nullptr },
+    { true, valid_string, "green", "5" },
+    { true, valid_string, "green", "6" },
+    { false, valid_string, "green", "4" },
+
+    { true, valid_select, "green", "red | green | yellow" },
+    { false, valid_select, "blue", "red | green | yellow" },
+    { false, valid_select, "green", nullptr },
+
+    { true, valid_enum, "green", "red | green | yellow" },
+    { false, valid_enum, "blue", "red | green | yellow" },
+    { false, valid_enum, "green", nullptr },
+
+    { true, valid_multi, "green", "red | green | yellow" },
+    { true, valid_multi, "red yellow", "red | green | yellow" },
+    { false, valid_multi, "redgreen", "red | green | yellow" },
+    { false, valid_multi, "blue", nullptr },
+
+    { true, valid_mac, "98:01:a7:9d:d8:41", nullptr },
+    { false, valid_mac, ":01:a7:9d:d8:41", nullptr },
+    { false, valid_mac, "01:a7:9d:d8:41", nullptr },
+    { false, valid_mac, "98:01:a7:9d:d8:419", nullptr },
+    { false, valid_mac, "98:01:a7:9d:d8:41x", nullptr },
+
+    { true, valid_ip4, "1.2.3.4", nullptr },
+    { true, valid_ip4, "1.2.3", nullptr },
+    { false, valid_ip4, "1.2.3.", nullptr },
+    { false, valid_ip4, "1.2.x", nullptr },
+
+    { true, valid_addr, "1.2.3.4", nullptr },
+    { true, valid_addr, "1.2.3.4/32", nullptr },
+    { true, valid_addr, "1.2.3.4/0", nullptr },
+    { false, valid_addr, "1.2.3.4/33", nullptr },
+    { false, valid_addr, "1.2.0x.4/33", nullptr },
+
+    { true, valid_addr, "2001:420:c0c4:1004::157", nullptr },
+    { true, valid_addr, "2001:420:c0c4:1004::157/128", nullptr },
+    { true, valid_addr, "2001:420:c0c4:1004::157/0", nullptr },
+    { false, valid_addr, "2001:420:c0c4:1004:0x:157/256", nullptr },
+
+    { true, valid_bit_list, "1 2", "3" },
+    { true, valid_bit_list, "1 2 3", "3" },
+    { false, valid_bit_list, "1 2 3 4", "3" },
+    { false, valid_bit_list, "128", "3" },
+
+    { false, nullptr, 0, nullptr }
+// __STRDUMP_ENABLE__
+};
+
+TEST_CASE("string", "[Parameter]")
+{
+    auto test = string_tests;
+
+    while ( test->validate )
+    {
+        Value v(test->value);
+        bool result = test->validate(v, test->range);
+        CHECK(result == test->expected);
+        ++test;
+    }
+}
+
+TEST_CASE("max", "[Parameter]")
+{
+    CHECK(get_int("max31") == 2147483647);
+    CHECK(get_int("max32") == 4294967295);
+    CHECK(get_int("max53") == 9007199254740992);
+
+    if ( sizeof(size_t) == 4 )
+        CHECK(get_int("maxSZ") == 4294967295);
+    else
+        CHECK(get_int("maxSZ") == 9007199254740992);
+}
+#endif
+
index 360e148243d94df2725805a507561c208a72bc39..c5ed8e6fb27d924acf43ac700b152bfbacddb585 100644 (file)
@@ -45,7 +45,7 @@ struct SO_PUBLIC Parameter
         PT_LIST,       // range is Parameter*, no default
         PT_DYNAMIC,    // range is RangeQuery*
         PT_BOOL,       // if you are reading this, get more coffee
-        PT_INT,        // signed 64 bits or less determined by range
+        PT_INT,        // signed 53 bits or less determined by range
         PT_INTERVAL,   // string that defines an interval, bounds within range
         PT_REAL,       // double
         PT_PORT,       // 0 to 64K-1 unless specified otherwise
index 12e2af3c1ae9c6f030ddfd50bf5a0bd91627e39b..281f2306aa75a3ec26d3f752dc5880f07cadc30b 100644 (file)
@@ -75,8 +75,8 @@ public:
     void set_enum(unsigned u)
     { type = VT_NUM; num = u;  }
 
-    void set_aux(unsigned u)
-    { num = u; }
+    void set_aux(uint64_t u)
+    { num = (double)u; }
 
     const char* get_name() const
     { return param ? param->name : nullptr; }
@@ -87,14 +87,38 @@ public:
     bool get_bool() const
     { return num != 0; }
 
-    long get_long() const
+    long get_long() const  // FIXIT-L to be removed
     { return (long)num; }
 
+    size_t get_size() const
+    { return (size_t)num; }
+
+    uint8_t get_uint8() const
+    { return (uint8_t)num; }
+
+    int16_t get_int16() const
+    { return (int16_t)num; }
+
+    uint16_t get_uint16() const
+    { return (uint16_t)num; }
+
+    int32_t get_int32() const
+    { return (int32_t)num; }
+
+    uint32_t get_uint32() const
+    { return (uint32_t)num; }
+
+    int64_t get_int64() const
+    { return (int64_t)num; }
+
+    uint64_t get_uint64() const
+    { return (uint64_t)num; }
+
     double get_real() const
     { return num; }
 
     const uint8_t* get_buffer(unsigned& n) const
-    { n = str.size(); return (const uint8_t*)str.data(); }
+    { n = (unsigned)str.size(); return (const uint8_t*)str.data(); }
 
     const char* get_string() const
     { return str.c_str(); }
index 4c463f0b297e76bc8c08abee50072cf8d0977baa..1330ac3fe6f7db11c3b863afa30646291a01778e 100644 (file)
@@ -30,7 +30,7 @@ using namespace snort;
 
 const Parameter HostCacheModule::host_cache_params[] =
 {
-    { "size", Parameter::PT_INT, nullptr, nullptr,
+    { "size", Parameter::PT_INT, "1:max32", nullptr,
       "size of host cache" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -39,7 +39,7 @@ const Parameter HostCacheModule::host_cache_params[] =
 bool HostCacheModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("size") )
-        host_cache_size = v.get_long();
+        host_cache_size = v.get_uint32();
     else
         return false;
 
index 415a3395e239ffe057d14d7dc6eea64382df58e3..0b175a91855d362cb770f9263546bd6b96820beb 100644 (file)
@@ -80,10 +80,10 @@ bool HostTrackerModule::set(const char*, Value& v, SnortConfig* sc)
         host->set_ip_addr(addr);
     }
     else if ( host and v.is("frag_policy") )
-        host->set_frag_policy(v.get_long() + 1);
+        host->set_frag_policy(v.get_uint8() + 1);
 
     else if ( host and v.is("tcp_policy") )
-        host->set_stream_policy(v.get_long() + 1);
+        host->set_stream_policy(v.get_uint8() + 1);
 
     else if ( v.is("name") )
         app.snort_protocol_id = sc->proto_ref->add(v.get_string());
@@ -92,7 +92,7 @@ bool HostTrackerModule::set(const char*, Value& v, SnortConfig* sc)
         app.ipproto = sc->proto_ref->add(v.get_string());
 
     else if ( v.is("port") )
-        app.port = v.get_long();
+        app.port = v.get_uint16();
 
     else
         return false;
index 9227e5e33274664e907be80fc046b582370408c1..f8b7e4b4376a5ccbcc3c8725d67a54378c4fd1a3 100644 (file)
@@ -182,13 +182,13 @@ static const Parameter s_params[] =
     { PRINT_OPT, Parameter::PT_IMPLIED, nullptr, nullptr,
       "dump decode data to console; always true" },
 
-    { LENGTH_OPT, Parameter::PT_INT, "0:", nullptr,
+    { LENGTH_OPT, Parameter::PT_INT, "0:max32", nullptr,
       "compares ASN.1 type lengths with the supplied argument" },
 
-    { ABS_OFFSET_OPT, Parameter::PT_INT, "0:", nullptr,
+    { ABS_OFFSET_OPT, Parameter::PT_INT, "0:65535", nullptr,
       "absolute offset from the beginning of the packet" },
 
-    { REL_OFFSET_OPT, Parameter::PT_INT, nullptr, nullptr,
+    { REL_OFFSET_OPT, Parameter::PT_INT, "-65535:65535", nullptr,
       "relative offset from the cursor" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -232,17 +232,17 @@ bool Asn1Module::set(const char*, Value& v, SnortConfig*)
     else if ( v.is(LENGTH_OPT) )
     {
         data.length = 1;
-        data.max_length = v.get_long();
+        data.max_length = v.get_uint32();
     }
     else if ( v.is(ABS_OFFSET_OPT) )
     {
         data.offset_type = ABS_OFFSET;
-        data.offset = v.get_long();
+        data.offset = v.get_uint16();
     }
     else if ( v.is(REL_OFFSET_OPT) )
     {
         data.offset_type = REL_OFFSET;
-        data.offset = v.get_long();
+        data.offset = v.get_int32();
     }
     else
         return false;
index 929f03c25f11e643a9ef3f3294702d9f65fa426f..1cce97ec8ebb9cb5f647f749d20163671eda0099 100644 (file)
@@ -168,10 +168,10 @@ IpsOption::EvalStatus Base64DecodeOption::eval(Cursor& c, Packet*)
 
 static const Parameter s_params[] =
 {
-    { "bytes", Parameter::PT_INT, "1:", nullptr,
+    { "bytes", Parameter::PT_INT, "1:max32", nullptr,
       "number of base64 encoded bytes to decode" },
 
-    { "offset", Parameter::PT_INT, "0:", "0",
+    { "offset", Parameter::PT_INT, "0:max32", "0",
       "bytes past start of buffer to start decoding" },
 
     { "relative", Parameter::PT_IMPLIED, nullptr, nullptr,
@@ -207,10 +207,10 @@ bool B64DecodeModule::begin(const char*, int, SnortConfig*)
 bool B64DecodeModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("bytes") )
-        data.bytes_to_decode = v.get_long();
+        data.bytes_to_decode = v.get_uint32();
 
     else if ( v.is("offset") )
-        data.offset = v.get_long();
+        data.offset = v.get_uint32();
 
     else if ( v.is("relative") )
         data.flags |= BASE64DECODE_RELATIVE_FLAG;
index 517f607d4fad671ebe0048a83aecee401529a6f1..395d3bde91a0c0262e94be29aadada1ee4cf2659 100644 (file)
@@ -375,10 +375,10 @@ bool ExtractModule::end(const char*, int, SnortConfig*)
 bool ExtractModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~count") )
-        data.bytes_to_grab = v.get_long();
+        data.bytes_to_grab = v.get_uint8();
 
     else if ( v.is("~offset") )
-        data.offset = v.get_long();
+        data.offset = v.get_int32();
 
     else if ( v.is("~name") )
         data.name = snort_strdup(v.get_string());
@@ -387,10 +387,10 @@ bool ExtractModule::set(const char*, Value& v, SnortConfig*)
         data.relative_flag = 1;
 
     else if ( v.is("align") )
-        data.align = v.get_long();
+        data.align = v.get_uint8();
 
     else if ( v.is("multiplier") )
-        data.multiplier = v.get_long();
+        data.multiplier = v.get_uint16();
 
     else if ( v.is("big") )
         set_byte_order(data.endianness, ENDIAN_BIG, "byte_extract");
@@ -416,7 +416,7 @@ bool ExtractModule::set(const char*, Value& v, SnortConfig*)
         data.base = 8;
 
     else if ( v.is("bitmask") )
-        data.bitmask_val = v.get_long();
+        data.bitmask_val = v.get_uint32();
 
     else
         return false;
index e95484486bd8f55bbe4000e3efe1a30995f1a2f9..34e82983d5a8d102d56fad721cf4881f0007a562 100644 (file)
@@ -465,7 +465,7 @@ bool ByteJumpModule::end(const char*, int, SnortConfig*)
 bool ByteJumpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~count") )
-        data.bytes_to_grab = v.get_long();
+        data.bytes_to_grab = v.get_uint8();
 
     else if ( v.is("~offset") )
     {
@@ -485,7 +485,7 @@ bool ByteJumpModule::set(const char*, Value& v, SnortConfig*)
         data.align_flag = 1;
 
     else if ( v.is("multiplier") )
-        data.multiplier = v.get_long();
+        data.multiplier = v.get_uint16();
 
     else if ( v.is("post_offset") )
     {
@@ -522,7 +522,7 @@ bool ByteJumpModule::set(const char*, Value& v, SnortConfig*)
         data.from_end_flag = 1;
 
     else if ( v.is("bitmask") )
-        data.bitmask_val = v.get_long();
+        data.bitmask_val = v.get_uint32();
     
     else
         return false;
index 89dbdb7a258e82c03b7064c2510fe3d652f581b1..48f91fa64377756ccbeb25a0a3c18ed2ededf886 100644 (file)
@@ -363,10 +363,10 @@ bool ByteMathModule::begin(const char*, int, SnortConfig*)
 bool ByteMathModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("bytes") )
-        data.bytes_to_extract = v.get_long();
+        data.bytes_to_extract = v.get_uint8();
 
     else if ( v.is("oper") )
-        data.oper = (BM_Oper)v.get_long();
+        data.oper = (BM_Oper)v.get_uint8();
 
     else if ( v.is("rvalue") )
     {
@@ -397,13 +397,13 @@ bool ByteMathModule::set(const char*, Value& v, SnortConfig*)
     else if ( v.is("string") )
     {
         data.string_convert_flag = true;
-        parse_base(v.get_long(), data);
+        parse_base(v.get_uint8(), data);
     }
     else if ( v.is("endian") )
-        parse_endian(v.get_long(), data);
+        parse_endian(v.get_uint8(), data);
 
     else if ( v.is("bitmask") )
-        data.bitmask_val = v.get_long();
+        data.bitmask_val = v.get_uint32();
 
     else if ( v.is("result") )
         data.result_name = snort_strdup(v.get_string());
index 62566f740a14b2329cef9cb447523002ceff66ef..4962c3ed3063f166eff59bb9bff0d00601eadc11 100644 (file)
@@ -532,7 +532,7 @@ bool ByteTestModule::end(const char*, int, SnortConfig*)
 bool ByteTestModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~count") )
-        data.bytes_to_compare = v.get_long();
+        data.bytes_to_compare = v.get_uint8();
 
     else if ( v.is("~operator") )
         parse_operator(v.get_string(), data);
@@ -580,7 +580,7 @@ bool ByteTestModule::set(const char*, Value& v, SnortConfig*)
         data.base = 8;
 
     else if ( v.is("bitmask") )
-        data.bitmask_val = v.get_long();
+        data.bitmask_val = v.get_uint32();
 
     else
         return false;
index 3c2bbbfc8f620d9f37319870819a715ed0a21e99..0ae0509c3dadae9d8d5bc262cf3a85f247f29d83 100644 (file)
@@ -613,10 +613,10 @@ static const Parameter s_params[] =
     { "fast_pattern", Parameter::PT_IMPLIED, nullptr, nullptr,
       "use this content in the fast pattern matcher instead of the content selected by default" },
 
-    { "fast_pattern_offset", Parameter::PT_INT, "0:", "0",
+    { "fast_pattern_offset", Parameter::PT_INT, "0:65535", "0",
       "number of leading characters of this content the fast pattern matcher should exclude" },
 
-    { "fast_pattern_length", Parameter::PT_INT, "1:", nullptr,
+    { "fast_pattern_length", Parameter::PT_INT, "1:65535", nullptr,
       "maximum number of characters from this content the fast pattern matcher should use" },
 
     { "offset", Parameter::PT_STRING, nullptr, nullptr,
@@ -730,12 +730,12 @@ bool ContentModule::set(const char*, Value& v, SnortConfig*)
 
     else if ( v.is("fast_pattern_offset") )
     {
-        cd->pmd.fp_offset = v.get_long();
+        cd->pmd.fp_offset = v.get_uint16();
         cd->pmd.set_fast_pattern();
     }
     else if ( v.is("fast_pattern_length") )
     {
-        cd->pmd.fp_length = v.get_long();
+        cd->pmd.fp_length = v.get_uint16();
         cd->pmd.set_fast_pattern();
     }
     else
index ace5efc986bb67fbb7d3b670ff78fa405d092745..ebbc86c3d867754b26d0a0fe1c554e1c293ec4be 100644 (file)
@@ -45,10 +45,10 @@ static const Parameter s_params[] =
     { "track", Parameter::PT_ENUM, "by_src | by_dst", nullptr,
       "track hits by source or destination IP address" },
 
-    { "count", Parameter::PT_INT, "1:", nullptr,
+    { "count", Parameter::PT_INT, "1:max32", nullptr,
       "hits in interval before allowing the rule to fire" },
 
-    { "seconds", Parameter::PT_INT, "1:", nullptr,
+    { "seconds", Parameter::PT_INT, "1:max32", nullptr,
       "length of interval to count hits" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -83,13 +83,13 @@ bool DetectionFilterModule::begin(const char*, int, SnortConfig* sc)
 bool DetectionFilterModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("track") )
-        thdx.tracking = v.get_long() ? THD_TRK_DST : THD_TRK_SRC;
+        thdx.tracking = v.get_uint8() ? THD_TRK_DST : THD_TRK_SRC;
 
     else if ( v.is("count") )
-        thdx.count = v.get_long();
+        thdx.count = v.get_uint32();
 
     else if ( v.is("seconds") )
-        thdx.seconds = v.get_long();
+        thdx.seconds = v.get_uint32();
 
     else
         return false;
index bcfe86c274563538493dc31cedb7283bc625d54e..06e37d7deb32bd19640ca46a537a99ff6e29c3c5 100644 (file)
@@ -36,7 +36,7 @@ using namespace snort;
 
 static const Parameter s_params[] =
 {
-    { "~", Parameter::PT_INT, "1:", nullptr,
+    { "~", Parameter::PT_INT, "1:max32", nullptr,
       "generator id" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    int gid;
+    uint32_t gid;
 };
 
 bool GidModule::set(const char*, Value& v, SnortConfig*)
@@ -63,7 +63,7 @@ bool GidModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    gid = v.get_long();
+    gid = v.get_uint32();
     return true;
 }
 
index ef0f4a10024fcf30d98999badd38f0c69f5d2e63..5624123ebefccf246bc1014792a2c9be5c3e5c46 100644 (file)
@@ -336,7 +336,7 @@ bool HashModule::set(const char*, Value& v, SnortConfig*)
         hmd->relative = true;
 
     else if ( v.is("length") )
-        hmd->length = v.get_long();
+        hmd->length = v.get_uint16();
 
     else
         return false;
index 238d717e2066939376f0d6f69e0686850223963a..372b05fd8590d39c0f1c5e487fb981fcd438107c 100644 (file)
@@ -272,52 +272,41 @@ static void pcre_parse(const char* data, PcreData* pcre_data)
 
     if (pcre_data->pe)
     {
-        if ((SnortConfig::get_pcre_match_limit() != -1) &&
+        if ((SnortConfig::get_pcre_match_limit() != 0) &&
             !(pcre_data->options & SNORT_OVERRIDE_MATCH_LIMIT))
         {
-            if (pcre_data->pe->flags & PCRE_EXTRA_MATCH_LIMIT)
-            {
-                pcre_data->pe->match_limit = SnortConfig::get_pcre_match_limit();
-            }
-            else
-            {
+            if ( !(pcre_data->pe->flags & PCRE_EXTRA_MATCH_LIMIT) )
                 pcre_data->pe->flags |= PCRE_EXTRA_MATCH_LIMIT;
-                pcre_data->pe->match_limit = SnortConfig::get_pcre_match_limit();
-            }
+
+            pcre_data->pe->match_limit = SnortConfig::get_pcre_match_limit();
         }
 
-        if ((SnortConfig::get_pcre_match_limit_recursion() != -1) &&
+        if ((SnortConfig::get_pcre_match_limit_recursion() != 0) &&
             !(pcre_data->options & SNORT_OVERRIDE_MATCH_LIMIT))
         {
-            if (pcre_data->pe->flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION)
-            {
-                pcre_data->pe->match_limit_recursion =
-                    SnortConfig::get_pcre_match_limit_recursion();
-            }
-            else
-            {
+            if ( !(pcre_data->pe->flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) )
                 pcre_data->pe->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
-                pcre_data->pe->match_limit_recursion =
-                    SnortConfig::get_pcre_match_limit_recursion();
-            }
+
+            pcre_data->pe->match_limit_recursion =
+                SnortConfig::get_pcre_match_limit_recursion();
         }
     }
     else
     {
         if (!(pcre_data->options & SNORT_OVERRIDE_MATCH_LIMIT) &&
-            ((SnortConfig::get_pcre_match_limit() != -1) ||
-             (SnortConfig::get_pcre_match_limit_recursion() != -1)))
+            ((SnortConfig::get_pcre_match_limit() != 0) ||
+             (SnortConfig::get_pcre_match_limit_recursion() != 0)))
         {
             pcre_data->pe = (pcre_extra*)snort_calloc(sizeof(pcre_extra));
             pcre_data->free_pe = true;
 
-            if (SnortConfig::get_pcre_match_limit() != -1)
+            if (SnortConfig::get_pcre_match_limit() != 0)
             {
                 pcre_data->pe->flags |= PCRE_EXTRA_MATCH_LIMIT;
                 pcre_data->pe->match_limit = SnortConfig::get_pcre_match_limit();
             }
 
-            if (SnortConfig::get_pcre_match_limit_recursion() != -1)
+            if (SnortConfig::get_pcre_match_limit_recursion() != 0)
             {
                 pcre_data->pe->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
                 pcre_data->pe->match_limit_recursion =
index 45f505331ff0820528183a5ad2d754d8c463ccbb..fb37efceb610f7fcb94c31050713ca3ed46556ac 100644 (file)
@@ -36,7 +36,7 @@ using namespace snort;
 
 static const Parameter s_params[] =
 {
-    { "~", Parameter::PT_INT, "1:", nullptr,
+    { "~", Parameter::PT_INT, "1:max31", nullptr,
       "relative severity level; 1 is highest priority" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -63,7 +63,7 @@ bool PriorityModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    priority = v.get_long();
+    priority = v.get_int32();
     return true;
 }
 
index 1e4acde5453b0875aa5b44062c8d0abc478e578b..6c6e5070d5f029777919af7550529e4aaa8ef145 100644 (file)
@@ -36,7 +36,7 @@ using namespace snort;
 
 static const Parameter s_params[] =
 {
-    { "~", Parameter::PT_INT, "1:", nullptr,
+    { "~", Parameter::PT_INT, "1:max32", nullptr,
       "revision" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    int rev;
+    uint32_t rev;
 };
 
 bool RevModule::set(const char*, Value& v, SnortConfig*)
@@ -63,7 +63,7 @@ bool RevModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    rev = v.get_long();
+    rev = v.get_uint32();
     return true;
 }
 
index 766aebc763e05321f034287e724350de021ca85a..1a09a3873eda66494cb7f2d48bfe923f1e59a722 100644 (file)
@@ -225,7 +225,7 @@ bool RpcOption::check_procedure(uint32_t procedure)
 
 static const Parameter s_params[] =
 {
-    { "~app", Parameter::PT_INT, nullptr, nullptr,
+    { "~app", Parameter::PT_INT, "0:max32", nullptr,
       "application number" },
 
     { "~ver", Parameter::PT_STRING, nullptr, nullptr,
@@ -269,7 +269,7 @@ bool RpcModule::begin(const char*, int, SnortConfig*)
 bool RpcModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~app") )
-        data.program = (uint32_t)v.get_long();
+        data.program = v.get_uint32();
 
     else if ( v.is("~ver") )
         return set(v, data.version, RPC_CHECK_VERSION);
index d16a3f2e5b75a9a390516650a94d072d65f67c38..b574c0d448c1f1a55f4fa7bf3e3a957c1e2b5724 100644 (file)
@@ -290,7 +290,7 @@ static const Parameter s_params[] =
     { "~pattern", Parameter::PT_STRING, nullptr, nullptr,
       "The pattern to search for" },
 
-    { "threshold", Parameter::PT_INT, "1", nullptr,
+    { "threshold", Parameter::PT_INT, "1:max32", "1",
       "number of matches before alerting" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -347,7 +347,7 @@ bool SdPatternModule::set(const char*, Value& v, SnortConfig* sc)
         config.pii.erase(config.pii.length()-1, 1);
     }
     else if ( v.is("threshold") )
-        config.threshold = v.get_long();
+        config.threshold = v.get_uint32();
     else
         return false;
 
index 55f1b4a493d544281c761c69e3b7c0fffedbb125..9ec87c9df03dee58cc4fcbde19466e3bca8cee81 100644 (file)
@@ -339,7 +339,7 @@ bool SsnModule::begin(const char*, int, SnortConfig*)
 bool SsnModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~mode") )
-        data.session_flag = v.get_long() + 1;
+        data.session_flag = v.get_uint8() + 1;
 
     else
         return false;
index 8a516578cf1ca8121f366c52af7d3e1a5162e95a..360897a837ab34ed172a8c4f8e1cd54207f185ff 100644 (file)
@@ -36,7 +36,7 @@ using namespace snort;
 
 static const Parameter s_params[] =
 {
-    { "~", Parameter::PT_INT, "1:", nullptr,
+    { "~", Parameter::PT_INT, "1:max32", nullptr,
       "signature id" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -55,7 +55,7 @@ public:
     { return DETECT; }
 
 public:
-    int sid;
+    uint32_t sid;
 };
 
 bool SidModule::set(const char*, Value& v, SnortConfig*)
@@ -63,7 +63,7 @@ bool SidModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    sid = v.get_long();
+    sid = v.get_uint32();
     return true;
 }
 
index 549b89c1b769320210e71016eb6faf57dc3b6a27..f23d0b4f3e74c63d63227036692eee2e5e7bd045 100644 (file)
@@ -42,13 +42,13 @@ static const Parameter s_params[] =
     { "~", Parameter::PT_ENUM, "session|host_src|host_dst", nullptr,
       "log all packets in session or all packets to or from host" },
 
-    { "packets", Parameter::PT_INT, "1:", nullptr,
+    { "packets", Parameter::PT_INT, "1:max32", nullptr,
       "tag this many packets" },
 
-    { "seconds", Parameter::PT_INT, "1:", nullptr,
+    { "seconds", Parameter::PT_INT, "1:max32", nullptr,
       "tag for this many seconds" },
 
-    { "bytes", Parameter::PT_INT, "1:", nullptr,
+    { "bytes", Parameter::PT_INT, "1:max32", nullptr,
       "tag for this many bytes" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -105,7 +105,7 @@ bool TagModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("~") )
     {
-        switch (v.get_long())
+        switch (v.get_uint8())
         {
         case 0:
             tag->tag_type = TAG_SESSION;
@@ -125,17 +125,17 @@ bool TagModule::set(const char*, Value& v, SnortConfig*)
     else if ( v.is("packets") )
     {
         tag->tag_metric |= TAG_METRIC_PACKETS;
-        tag->tag_packets = v.get_long();
+        tag->tag_packets = v.get_uint32();
     }
     else if ( v.is("seconds") )
     {
         tag->tag_metric |= TAG_METRIC_SECONDS;
-        tag->tag_seconds = v.get_long();
+        tag->tag_seconds = v.get_uint32();
     }
     else if ( v.is("bytes") )
     {
         tag->tag_metric |= TAG_METRIC_BYTES;
-        tag->tag_bytes = v.get_long();
+        tag->tag_bytes = v.get_uint32();
     }
     else
         return false;
index 737e76990b0a360cced485d6b517ed104901c531..1c22de31b13e654ee559546667d77e0cbd04a3a1 100644 (file)
@@ -63,8 +63,8 @@ bool TargetModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    assert(v.get_long() >= 0 and v.get_long() <= TARGET_MAX);
-    target = static_cast<Target>(v.get_long() + 1);
+    assert(v.get_uint8() <= TARGET_MAX);
+    target = static_cast<Target>(v.get_uint8() + 1);
 
     return true;
 }
index 482c9eb3efa6e7731883094ece6c6498485c41c2..bda8881a8868076bcf6e2a10dce0b8611440a385 100644 (file)
@@ -44,7 +44,7 @@ using namespace snort;
 
 static const Parameter s_packet_params[] =
 {
-    { "max_time", Parameter::PT_INT, "0:", "500",
+    { "max_time", Parameter::PT_INT, "0:max53", "500",
         "set timeout for packet latency thresholding (usec)" },
 
     { "fastpath", Parameter::PT_BOOL, nullptr, "false",
@@ -58,7 +58,7 @@ static const Parameter s_packet_params[] =
 
 static const Parameter s_rule_params[] =
 {
-    { "max_time", Parameter::PT_INT, "0:", "500",
+    { "max_time", Parameter::PT_INT, "0:max53", "500",
         "set timeout for rule evaluation (usec)" },
 
     // We could just treat suspend_threshold == 0 as suspend == false
@@ -66,10 +66,10 @@ static const Parameter s_rule_params[] =
     { "suspend", Parameter::PT_BOOL, nullptr, "false",
         "temporarily suspend expensive rules" },
 
-    { "suspend_threshold", Parameter::PT_INT, "1:", "5",
+    { "suspend_threshold", Parameter::PT_INT, "1:max32", "5",
         "set threshold for number of timeouts before suspending a rule" },
 
-    { "max_suspend_time", Parameter::PT_INT, "0:", "30000",
+    { "max_suspend_time", Parameter::PT_INT, "0:max32", "30000",
         "set max time for suspending a rule (ms, 0 means permanently disable rule)" },
 
     { "action", Parameter::PT_ENUM, "none | alert | log | alert_and_log", "none",
@@ -120,7 +120,7 @@ static inline bool latency_set(Value& v, PacketLatencyConfig& config)
 {
     if ( v.is("max_time") )
     {
-        long t = clock_ticks(v.get_long());
+        long t = clock_ticks(v.get_int64());
         config.max_time = TO_DURATION(config.max_time, t);
     }
     else if ( v.is("fastpath") )
@@ -128,7 +128,7 @@ static inline bool latency_set(Value& v, PacketLatencyConfig& config)
 
     else if ( v.is("action") )
         config.action =
-            static_cast<decltype(config.action)>(v.get_long());
+            static_cast<decltype(config.action)>(v.get_uint8());
     else
         return false;
 
@@ -139,23 +139,23 @@ static inline bool latency_set(Value& v, RuleLatencyConfig& config)
 {
     if ( v.is("max_time") )
     {
-        long t = clock_ticks(v.get_long());
+        long t = clock_ticks(v.get_uint64());
         config.max_time = TO_DURATION(config.max_time, t);
     }
     else if ( v.is("suspend") )
         config.suspend = v.get_bool();
 
     else if ( v.is("suspend_threshold") )
-        config.suspend_threshold = v.get_long();
+        config.suspend_threshold = v.get_uint32();
 
     else if ( v.is("max_suspend_time") )
     {
-        long t = clock_ticks(v.get_long());
+        long t = clock_ticks(v.get_uint32());
         config.max_suspend_time = TO_DURATION(config.max_time, t);
     }
     else if ( v.is("action") )
         config.action =
-            static_cast<decltype(config.action)>(v.get_long());
+            static_cast<decltype(config.action)>(v.get_uint8());
     else
         return false;
 
index f3a3d3970c2ca6d533d368d02d3adbcdeb9dad10..5dc662c69bc08912741b0c1f42d585e0979ac831 100644 (file)
@@ -470,7 +470,7 @@ static const Parameter s_params[] =
     { "fields", Parameter::PT_MULTI, csv_range, csv_deflt,
       "selected fields will be output in given order left to right" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { "separator", Parameter::PT_STRING, nullptr, ", ",
@@ -495,8 +495,8 @@ public:
 
 public:
     bool file;
+    size_t limit;
     string sep;
-    unsigned long limit;
     vector<CsvFunc> fields;
 };
 
@@ -516,7 +516,7 @@ bool CsvModule::set(const char*, Value& v, SnortConfig*)
     }
 
     else if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else if ( v.is("separator") )
         sep = v.get_string();
index 412c1d1473a017841af32fb9dac72b79900e0cbd..db9d7f822ff79f4cbb7947cbf4a069c94ea9835c 100644 (file)
@@ -80,7 +80,7 @@ static const Parameter s_params[] =
     { "packet", Parameter::PT_BOOL, nullptr, "false",
       "output packet dump with alert" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -101,8 +101,8 @@ public:
     { return CONTEXT; }
 
 public:
+    size_t limit;
     bool file;
-    unsigned long limit;
     bool packet;
 };
 
@@ -115,7 +115,7 @@ bool FastModule::set(const char*, Value& v, SnortConfig*)
         packet = v.get_bool();
 
     else if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else
         return false;
index 4bc294016d925760d8f2a627f614b2a915b94af2..faa4ef98e40d1c53ea3c07c7bf36240cddbaeeb3 100644 (file)
@@ -66,7 +66,7 @@ static const Parameter s_params[] =
     { "file", Parameter::PT_BOOL, nullptr, "false",
       "output to " F_NAME " instead of stdout" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -88,7 +88,7 @@ public:
 
 public:
     bool file;
-    unsigned long limit;
+    size_t limit;
 };
 
 bool FullModule::set(const char*, Value& v, SnortConfig*)
@@ -97,7 +97,7 @@ bool FullModule::set(const char*, Value& v, SnortConfig*)
         file = v.get_bool();
 
     else if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else
         return false;
index 073cadb9a6c7db1b6a690ad4caa04c051b23f39a..e5e12065d618a180c33078439b11a21cb2f53b84 100644 (file)
@@ -634,7 +634,7 @@ static const Parameter s_params[] =
     { "fields", Parameter::PT_MULTI, json_range, json_deflt,
       "selected fields will be output in given order left to right" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { "separator", Parameter::PT_STRING, nullptr, ", ",
@@ -659,8 +659,8 @@ public:
 
 public:
     bool file;
+    size_t limit;
     string sep;
-    unsigned long limit;
     vector<JsonFunc> fields;
 };
 
@@ -680,7 +680,7 @@ bool JsonModule::set(const char*, Value& v, SnortConfig*)
     }
 
     else if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else if ( v.is("separator") )
         sep = v.get_string();
index 0d17fe7ce1e73490ecb3b975bdd8dcb941e7d225..8462fcbaf8f9ba991a3f2dc782c95e6c096cd43c 100644 (file)
@@ -67,10 +67,10 @@ typedef vector<RuleId> RuleVector;
 
 static const Parameter rule_params[] =
 {
-    { "gid", Parameter::PT_INT, "1:", "1",
+    { "gid", Parameter::PT_INT, "1:max32", "1",
       "rule generator ID" },
 
-    { "sid", Parameter::PT_INT, "1:", "1",
+    { "sid", Parameter::PT_INT, "1:max32", "1",
       "rule signature ID" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -114,10 +114,10 @@ bool SfSocketModule::set(const char*, Value& v, SnortConfig*)
         file = v.get_string();
 
     else if ( v.is("gid") )
-        rule.gid = v.get_long();
+        rule.gid = v.get_uint32();
 
     else if ( v.is("sid") )
-        rule.sid = v.get_long();
+        rule.sid = v.get_uint32();
 
     return true;
 }
index 0f6edce6e4cdd72c9931a054f4b9e2134e1e5183..fabf9bb33b3e72899ad93e48075ec938a2998479 100644 (file)
@@ -159,10 +159,10 @@ public:
 bool SyslogModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("facility") )
-        facility = get_facility(v.get_long());
+        facility = get_facility(v.get_uint8());
 
     else if ( v.is("level") )
-        level = get_level(v.get_long());
+        level = get_level(v.get_uint8());
 
     else if ( v.is("options") )
         options = get_options(v.get_string());
index 8184709288c6f795b9355be503387d7a0e7feec5..9abecd43a6eb178ae980b88096bf2daa697c9d47 100644 (file)
@@ -168,10 +168,10 @@ static const Parameter s_params[] =
     { "raw", Parameter::PT_BOOL, nullptr, "false",
       "output all full packets if true, else just TCP payload" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
-    { "width", Parameter::PT_INT, "0:", "20",
+    { "width", Parameter::PT_INT, "0:max32", "20",
       "set line width (0 is unlimited)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -191,7 +191,7 @@ public:
 public:
     bool file;
     bool raw;
-    unsigned long limit;
+    size_t limit;
     unsigned width;
 };
 
@@ -204,10 +204,10 @@ bool HextModule::set(const char*, Value& v, SnortConfig*)
         raw = v.get_bool();
 
     else if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else if ( v.is("width") )
-        width = v.get_long();
+        width = v.get_uint32();
 
     else
         return false;
index ffb7c4b427d68eb204b4b2842130ef06d968ccc4..62ac36196581a6b4fcf8947f4bcb87ba36d40a1c 100644 (file)
@@ -74,7 +74,7 @@ static void TcpdumpRollLogFile(LtdConfig*);
 
 static const Parameter s_params[] =
 {
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -95,13 +95,13 @@ public:
     { return CONTEXT; }
 
 public:
-    unsigned long limit;
+    size_t limit;
 };
 
 bool TcpdumpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else
         return false;
@@ -159,7 +159,7 @@ static void TcpdumpInitLogFile(LtdConfig*, bool no_timestamp)
     if(!no_timestamp)
     {
         char timestamp[16];
-        snprintf(timestamp, sizeof(timestamp), ".%lu", context.lastTime);
+        snprintf(timestamp, sizeof(timestamp), ".%lu", (unsigned long)context.lastTime);
         filename += timestamp;
     }
 
index 74b950afa2b1247f42a90078bea0b99e8bf4313b..f0b067ce251b0b4876276ef72215db42dcd99ed1 100644 (file)
@@ -62,7 +62,7 @@ using namespace std;
 
 struct Unified2Config
 {
-    unsigned int limit;
+    size_t limit;
     int nostamp;
     bool legacy_events;
 };
@@ -788,7 +788,7 @@ static const Parameter s_params[] =
     { "legacy_events", Parameter::PT_BOOL, nullptr, "false",
       "generate Snort 2.X style events for barnyard2 compatibility" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:maxSZ", "0",
       "set maximum size in MB before rollover (0 is unlimited)" },
 
     { "nostamp", Parameter::PT_BOOL, nullptr, "true",
@@ -812,7 +812,7 @@ public:
     { return CONTEXT; }
 
 public:
-    unsigned limit;
+    size_t limit;
     bool nostamp;
     bool legacy_events;
 };
@@ -820,7 +820,7 @@ public:
 bool U2Module::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("limit") )
-        limit = v.get_long() * 1024 * 1024;
+        limit = v.get_size() * 1024 * 1024;
 
     else if ( v.is("nostamp") )
         nostamp = v.get_bool();
index e80fd1ccfe3404152b7cf727be7a091058dc21fa..f1b3d346ff3bea34df2264417f78b3fcd207927e 100644 (file)
 using namespace snort;
 using namespace std;
 
-#define snort_help \
-    "\n" \
-    "Snort has several options to get more help:\n" \
-    "\n" \
-    "-? list command line options (same as --help)\n" \
-    "--help this overview of help\n" \
-    "--help-commands [<module prefix>] output matching commands\n" \
-    "--help-config [<module prefix>] output matching config options\n" \
-    "--help-counts [<module prefix>] output matching peg counts\n" \
-    "--help-module <module> output description of given module\n" \
-    "--help-modules list all available modules with brief help\n" \
-    "--help-plugins list all available plugins with brief help\n" \
-    "--help-options [<option prefix>] output matching command line options\n" \
-    "--help-signals dump available control signals\n" \
-    "--list-buffers output available inspection buffers\n" \
-    "--list-builtin [<module prefix>] output matching builtin rules\n" \
-    "--list-gids [<module prefix>] output matching generators\n" \
-    "--list-modules [<module type>] list all known modules\n" \
-    "--list-plugins list all known modules\n" \
-    "--show-plugins list module and plugin versions\n" \
-    "\n" \
-    "--help* and --list* options preempt other processing so should be last on the\n" \
-    "command line since any following options are ignored.  To ensure options like\n" \
-    "--markup and --plugin-path take effect, place them ahead of the help or list\n" \
-    "options.\n" \
-    "\n" \
-    "Options that filter output based on a matching prefix, such as --help-config\n" \
-    "won't output anything if there is no match.  If no prefix is given, everything\n" \
-    "matches.\n" \
-    "\n" \
-    "Report bugs to bugs@snort.org.\n"
+static constexpr const char* snort_help =
+    "\n"
+    "Snort has several options to get more help:\n"
+    "\n"
+    "-? list command line options (same as --help)\n"
+    "--help this overview of help\n"
+    "--help-commands [<module prefix>] output matching commands\n"
+    "--help-config [<module prefix>] output matching config options\n"
+    "--help-counts [<module prefix>] output matching peg counts\n"
+    "--help-limits print the int upper bounds denoted by max*\n"
+    "--help-module <module> output description of given module\n"
+    "--help-modules list all available modules with brief help\n"
+    "--help-plugins list all available plugins with brief help\n"
+    "--help-options [<option prefix>] output matching command line options\n"
+    "--help-signals dump available control signals\n"
+    "--list-buffers output available inspection buffers\n"
+    "--list-builtin [<module prefix>] output matching builtin rules\n"
+    "--list-gids [<module prefix>] output matching generators\n"
+    "--list-modules [<module type>] list all known modules\n"
+    "--list-plugins list all known modules\n"
+    "--show-plugins list module and plugin versions\n"
+    "\n"
+    "--help* and --list* options preempt other processing so should be last on the\n"
+    "command line since any following options are ignored.  To ensure options like\n"
+    "--markup and --plugin-path take effect, place them ahead of the help or list\n"
+    "options.\n"
+    "\n"
+    "Options that filter output based on a matching prefix, such as --help-config\n"
+    "won't output anything if there is no match.  If no prefix is given, everything\n"
+    "matches.\n"
+    "\n"
+    "Report bugs to bugs@snort.org.\n";
 
 //-------------------------------------------------------------------------
 
@@ -81,7 +82,7 @@ void help_args(const char* pfx)
 {
     Module* m = get_snort_module();
     const Parameter* p = m->get_parameters();
-    unsigned n = pfx ? strlen(pfx) : 0;
+    size_t n = pfx ? strlen(pfx) : 0;
 
     while ( p->name )
     {
@@ -246,6 +247,16 @@ void config_markup(SnortConfig*, const char*)
     show_help(sc, val, HT_PEG);
 }
 
+[[noreturn]] void help_limits(SnortConfig*, const char*)
+{
+    fprintf(stdout, "limits:\n");
+    fprintf(stdout, "max31 = 2147483647\n");
+    fprintf(stdout, "max32 = 4294967295\n");
+    fprintf(stdout, "max53 = 9007199254740992\n");
+    fprintf(stdout, "maxSZ = %zu\n", (sizeof(size_t) == 4) ? 4294967295 : 9007199254740992);
+    exit(0);
+}
+
 [[noreturn]] void help_module(SnortConfig* sc, const char* val)
 {
     show_help(sc, val, HT_MOD);
index 6d7be6ae6c9fc45ca2f1b2e4303720aef47576af..96f2d84f8bd9090479fedb80e36dff38edf40da7 100644 (file)
@@ -31,27 +31,29 @@ struct SnortConfig;
 void config_markup(snort::SnortConfig*, const char*);
 
 void help_args(const char* pfx);
+
 [[noreturn]] void help_basic(snort::SnortConfig*, const char*);
-[[noreturn]] void help_usage(snort::SnortConfig*, const char*);
-[[noreturn]] void help_options(snort::SnortConfig*, const char*);
-[[noreturn]] void help_signals(snort::SnortConfig*, const char*);
-[[noreturn]] void help_config(snort::SnortConfig* sc, const char*);
-[[noreturn]] void help_commands(snort::SnortConfig* sc, const char*);
-[[noreturn]] void help_gids(snort::SnortConfig* sc, const char*);
 [[noreturn]] void help_buffers(snort::SnortConfig* sc, const char*);
 [[noreturn]] void help_builtin(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_commands(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_config(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_counts(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_gids(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_limits(snort::SnortConfig* sc, const char*);
 [[noreturn]] void help_module(snort::SnortConfig* sc, const char*);
 [[noreturn]] void help_modules(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_options(snort::SnortConfig*, const char*);
 [[noreturn]] void help_plugins(snort::SnortConfig* sc, const char*);
+[[noreturn]] void help_signals(snort::SnortConfig*, const char*);
+[[noreturn]] void help_usage(snort::SnortConfig*, const char*);
 [[noreturn]] void help_version(snort::SnortConfig*);
-[[noreturn]] void help_counts(snort::SnortConfig* sc, const char*);
 
+[[noreturn]] void list_daqs(snort::SnortConfig* sc);
 [[noreturn]] void list_modules(snort::SnortConfig* sc, const char*);
 [[noreturn]] void list_plugins(snort::SnortConfig* sc, const char*);
-[[noreturn]] void list_daqs(snort::SnortConfig* sc);
 
-[[noreturn]] void dump_defaults(snort::SnortConfig* sc, const char*);
 [[noreturn]] void dump_builtin_rules(snort::SnortConfig* sc, const char*);
+[[noreturn]] void dump_defaults(snort::SnortConfig* sc, const char*);
 [[noreturn]] void dump_dynamic_rules(snort::SnortConfig* sc, const char*);
 [[noreturn]] void dump_msg_map(snort::SnortConfig* sc, const char*);
 [[noreturn]] void dump_rule_hex(snort::SnortConfig* sc, const char*);
index 5fb9a1c341470b9c7887dae611ff392ee5ac9984..7099ed77a0f8502f908eb62204011bd9c55fcd67 100755 (executable)
@@ -69,23 +69,23 @@ using namespace std;
 /* *INDENT-OFF* */   //  Uncrustify handles this section incorrectly.
 static const Parameter detection_params[] =
 {
-    { "asn1", Parameter::PT_INT, "0:256", "0",
+    { "asn1", Parameter::PT_INT, "0:65535", "0",
       "maximum decode nodes" },
 
-    { "offload_limit", Parameter::PT_INT, "0:", "99999",
+    { "offload_limit", Parameter::PT_INT, "0:max32", "99999",
       "minimum sizeof PDU to offload fast pattern search (defaults to disabled)" },
 
-    { "offload_threads", Parameter::PT_INT, "0:", "0",
+    { "offload_threads", Parameter::PT_INT, "0:max32", "0",
       "maximum number of simultaneous offloads (defaults to disabled)" },
 
     { "pcre_enable", Parameter::PT_BOOL, nullptr, "true",
       "disable pcre pattern matching" },
 
-    { "pcre_match_limit", Parameter::PT_INT, "-1:1000000", "1500",
-      "limit pcre backtracking, -1 = max, 0 = off" },
+    { "pcre_match_limit", Parameter::PT_INT, "0:max32", "1500",
+      "limit pcre backtracking, 0 = off" },
 
-    { "pcre_match_limit_recursion", Parameter::PT_INT, "-1:10000", "1500",
-      "limit pcre stack consumption, -1 = max, 0 = off" },
+    { "pcre_match_limit_recursion", Parameter::PT_INT, "0:max32", "1500",
+      "limit pcre stack consumption, 0 = off" },
 
     { "enable_address_anomaly_checks", Parameter::PT_BOOL, nullptr, "false",
       "enable check and alerting of address anomalies" },
@@ -117,22 +117,22 @@ public:
 bool DetectionModule::set(const char* fqn, Value& v, SnortConfig* sc)
 {
     if ( v.is("asn1") )
-        sc->asn1_mem = v.get_long();
+        sc->asn1_mem = v.get_uint16();
 
     else if ( v.is("offload_limit") )
-        sc->offload_limit = v.get_long();
+        sc->offload_limit = v.get_uint32();
 
     else if ( v.is("offload_threads") )
-        sc->offload_threads = v.get_long();
+        sc->offload_threads = v.get_uint32();
 
     else if ( v.is("pcre_enable") )
         v.update_mask(sc->run_flags, RUN_FLAG__NO_PCRE, true);
 
     else if ( v.is("pcre_match_limit") )
-        sc->pcre_match_limit = v.get_long();
+        sc->pcre_match_limit = v.get_uint32();
 
     else if ( v.is("pcre_match_limit_recursion") )
-        sc->pcre_match_limit_recursion = v.get_long();
+        sc->pcre_match_limit_recursion = v.get_uint32();
 
     else if ( v.is("enable_address_anomaly_checks") )
         sc->address_anomaly_check_enabled = v.get_bool();
@@ -149,10 +149,10 @@ bool DetectionModule::set(const char* fqn, Value& v, SnortConfig* sc)
 
 static const Parameter event_queue_params[] =
 {
-    { "max_queue", Parameter::PT_INT, "1:", "8",
+    { "max_queue", Parameter::PT_INT, "1:max32", "8",
       "maximum events to queue" },
 
-    { "log", Parameter::PT_INT, "1:", "3",
+    { "log", Parameter::PT_INT, "1:max32", "3",
       "maximum events to log" },
 
     { "order_events", Parameter::PT_ENUM,
@@ -183,14 +183,14 @@ bool EventQueueModule::set(const char*, Value& v, SnortConfig* sc)
     EventQueueConfig* eq = sc->event_queue_config;
 
     if ( v.is("max_queue") )
-        eq->max_events = v.get_long();
+        eq->max_events = v.get_uint32();
 
     else if ( v.is("log") )
-        eq->log_events = v.get_long();
+        eq->log_events = v.get_uint32();
 
     else if ( v.is("order_events") )
     {
-        if ( v.get_long() )
+        if ( v.get_uint8() )
             eq->order = SNORT_EVENTQ_CONTENT_LEN;
         else
             eq->order = SNORT_EVENTQ_PRIORITY;
@@ -216,7 +216,7 @@ function<const char*()> get_search_methods = []()
 
 static const Parameter search_engine_params[] =
 {
-    { "bleedover_port_limit", Parameter::PT_INT, "1:", "1024",
+    { "bleedover_port_limit", Parameter::PT_INT, "1:max32", "1024",
       "maximum ports in rule before demotion to any-any port group" },
 
     { "bleedover_warnings_enabled", Parameter::PT_BOOL, nullptr, "false",
@@ -240,7 +240,7 @@ static const Parameter search_engine_params[] =
     { "debug_print_rule_groups_compiled", Parameter::PT_BOOL, nullptr, "false",
       "prints compiled rule group information" },
 
-    { "max_pattern_len", Parameter::PT_INT, "0:", "0",
+    { "max_pattern_len", Parameter::PT_INT, "0:max32", "0",
       "truncate patterns when compiling into state machine (0 means no maximum)" },
 
     { "max_queue_events", Parameter::PT_INT, "2:100", "5",  // upper bound is MAX_EVENT_MATCH
@@ -305,7 +305,7 @@ bool SearchEngineModule::set(const char*, Value& v, SnortConfig* sc)
     FastPatternConfig* fp = sc->fast_pattern_config;
 
     if ( v.is("bleedover_port_limit") )
-        fp->set_bleed_over_port_limit(v.get_long());
+        fp->set_bleed_over_port_limit(v.get_uint32());
 
     else if ( v.is("bleedover_warnings_enabled") )
     {
@@ -343,10 +343,10 @@ bool SearchEngineModule::set(const char*, Value& v, SnortConfig* sc)
             fp->set_debug_print_rule_groups_compiled();
     }
     else if ( v.is("max_pattern_len") )
-        fp->set_max_pattern_len(v.get_long());
+        fp->set_max_pattern_len(v.get_uint32());
 
     else if ( v.is("max_queue_events") )
-        fp->set_max_queue_events(v.get_long());
+        fp->set_max_queue_events(v.get_uint8());
 
     else if ( v.is("detect_raw_tcp") )
         fp->set_stream_insert(v.get_bool());
@@ -357,13 +357,13 @@ bool SearchEngineModule::set(const char*, Value& v, SnortConfig* sc)
             return false;
     }
     else if ( v.is("search_optimize") )
-        fp->set_search_opt(v.get_long());
+        fp->set_search_opt(v.get_bool());
 
     else if ( v.is("show_fast_patterns") )
         fp->set_debug_print_fast_patterns(v.get_bool());
 
     else if ( v.is("split_any_any") )
-        fp->set_split_any_any(v.get_long());
+        fp->set_split_any_any(v.get_bool());
 
     else
         return false;
@@ -380,14 +380,14 @@ static const Parameter profiler_time_params[] =
     { "show", Parameter::PT_BOOL, nullptr, "true",
       "show module time profile stats" },
 
-    { "count", Parameter::PT_INT, "0:", "0",
+    { "count", Parameter::PT_INT, "0:max32", "0",
       "limit results to count items per level (0 = no limit)" },
 
     { "sort", Parameter::PT_ENUM,
       "none | checks | avg_check | total_time ",
       "total_time", "sort by given field" },
 
-    { "max_depth", Parameter::PT_INT, "-1:", "-1",
+    { "max_depth", Parameter::PT_INT, "-1:255", "-1",
       "limit depth to max_depth (-1 = no limit)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -398,14 +398,14 @@ static const Parameter profiler_memory_params[] =
     { "show", Parameter::PT_BOOL, nullptr, "true",
       "show module memory profile stats" },
 
-    { "count", Parameter::PT_INT, "0:", "0",
+    { "count", Parameter::PT_INT, "0:max32", "0",
       "limit results to count items per level (0 = no limit)" },
 
     { "sort", Parameter::PT_ENUM,
       "none | allocations | total_used | avg_allocation ",
       "total_used", "sort by given field" },
 
-    { "max_depth", Parameter::PT_INT, "-1:", "-1",
+    { "max_depth", Parameter::PT_INT, "-1:255", "-1",
       "limit depth to max_depth (-1 = no limit)" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -416,7 +416,7 @@ static const Parameter profiler_rule_params[] =
     { "show", Parameter::PT_BOOL, nullptr, "true",
       "show rule time profile stats" },
 
-    { "count", Parameter::PT_INT, "0:", "0",
+    { "count", Parameter::PT_INT, "0:max32", "0",
       "print results to given level (0 = all)" },
 
     { "sort", Parameter::PT_ENUM,
@@ -446,7 +446,7 @@ static const Parameter profiler_params[] =
 
 template<typename T>
 static bool s_profiler_module_set_max_depth(T& config, Value& v)
-{ config.max_depth = v.get_long(); return true; }
+{ config.max_depth = v.get_uint8(); return true; }
 
 static bool s_profiler_module_set_max_depth(RuleProfilerConfig&, Value&)
 { return false; }
@@ -455,13 +455,13 @@ template<typename T>
 static bool s_profiler_module_set(T& config, Value& v)
 {
     if ( v.is("count") )
-        config.count = v.get_long();
+        config.count = v.get_uint32();
 
     else if ( v.is("show") )
         config.show = v.get_bool();
 
     else if ( v.is("sort") )
-        config.sort = static_cast<typename T::Sort>(v.get_long());
+        config.sort = static_cast<typename T::Sort>(v.get_uint8());
 
     else if ( v.is("max_depth") )
         return s_profiler_module_set_max_depth(config, v);
@@ -514,7 +514,7 @@ static const Parameter classification_params[] =
     { "name", Parameter::PT_STRING, nullptr, nullptr,
       "name used with classtype rule option" },
 
-    { "priority", Parameter::PT_INT, "0:", "1",
+    { "priority", Parameter::PT_INT, "0:max32", "1",
       "default priority for class" },
 
     { "text", Parameter::PT_STRING, nullptr, nullptr,
@@ -539,7 +539,7 @@ public:
 private:
     string name;
     string text;
-    int priority;
+    unsigned priority;
 };
 
 bool ClassificationsModule::begin(const char*, int, SnortConfig*)
@@ -563,7 +563,7 @@ bool ClassificationsModule::set(const char*, Value& v, SnortConfig*)
         name = v.get_string();
 
     else if ( v.is("priority") )
-        priority = v.get_long();
+        priority = v.get_uint32();
 
     else if ( v.is("text") )
         text = v.get_string();
@@ -650,11 +650,11 @@ static const Parameter alerts_params[] =
     { "default_rule_state", Parameter::PT_BOOL, nullptr, "true",
       "enable or disable ips rules" },
 
-    { "detection_filter_memcap", Parameter::PT_INT, "0:", "1048576",
-      "set available bytes of memory for detection_filters" },
+    { "detection_filter_memcap", Parameter::PT_INT, "0:max32", "1048576",
+      "set available MB of memory for detection_filters" },
 
-    { "event_filter_memcap", Parameter::PT_INT, "0:", "1048576",
-      "set available bytes of memory for event_filters" },
+    { "event_filter_memcap", Parameter::PT_INT, "0:max32", "1048576",
+      "set available MB of memory for event_filters" },
 
     { "log_references", Parameter::PT_BOOL, nullptr, "false",
       "include rule references in alert info (full only)" },
@@ -662,8 +662,8 @@ static const Parameter alerts_params[] =
     { "order", Parameter::PT_STRING, nullptr, "pass drop alert log",
       "change the order of rule action application" },
 
-    { "rate_filter_memcap", Parameter::PT_INT, "0:", "1048576",
-      "set available bytes of memory for rate_filters" },
+    { "rate_filter_memcap", Parameter::PT_INT, "0:max32", "1048576",
+      "set available MB of memory for rate_filters" },
 
     { "reference_net", Parameter::PT_STRING, nullptr, nullptr,
       "set the CIDR for homenet "
@@ -700,10 +700,10 @@ bool AlertsModule::set(const char*, Value& v, SnortConfig* sc)
         sc->default_rule_state = v.get_bool();
 
     else if ( v.is("detection_filter_memcap") )
-        sc->detection_filter_config->memcap = v.get_long();
+        sc->detection_filter_config->memcap = v.get_uint32();
 
     else if ( v.is("event_filter_memcap") )
-        sc->threshold_config->memcap = v.get_long();
+        sc->threshold_config->memcap = v.get_uint32();
 
     else if ( v.is("log_references") )
         v.update_mask(sc->output_flags, OUTPUT_FLAG__ALERT_REFS);
@@ -712,7 +712,7 @@ bool AlertsModule::set(const char*, Value& v, SnortConfig* sc)
         OrderRuleLists(sc, v.get_string());
 
     else if ( v.is("rate_filter_memcap") )
-        sc->rate_filter_config->memcap = v.get_long();
+        sc->rate_filter_config->memcap = v.get_uint32();
 
     else if ( v.is("reference_net") )
         return ( sc->homenet.set(v.get_string()) == SFIP_SUCCESS );
@@ -770,7 +770,7 @@ static const Parameter output_params[] =
     { "show_year", Parameter::PT_BOOL, nullptr, "false",
       "include year in timestamp in the alert and log files (same as -y)" },
 
-    { "tagged_packet_limit", Parameter::PT_INT, "0:", "256",
+    { "tagged_packet_limit", Parameter::PT_INT, "0:max32", "256",
       "maximum number of packets tagged for non-packet metrics" },
 
     { "verbose", Parameter::PT_BOOL, nullptr, "false",
@@ -817,7 +817,7 @@ bool OutputModule::set(const char*, Value& v, SnortConfig* sc)
         sc->log_dir = v.get_string();
 
     else if ( v.is("max_data") )
-        sc->event_trace_max = v.get_long();
+        sc->event_trace_max = v.get_uint16();
 
     else if ( v.is("obfuscate") )
         v.update_mask(sc->output_flags, OUTPUT_FLAG__OBFUSCATE);
@@ -829,7 +829,7 @@ bool OutputModule::set(const char*, Value& v, SnortConfig* sc)
         v.update_mask(sc->output_flags, OUTPUT_FLAG__INCLUDE_YEAR);
 
     else if ( v.is("tagged_packet_limit") )
-        sc->tagged_packet_limit = v.get_long();
+        sc->tagged_packet_limit = v.get_uint32();
 
     else if ( v.is("verbose") )
         v.update_mask(sc->logging_flags, LOGGING_FLAG__VERBOSE);
@@ -849,7 +849,7 @@ bool OutputModule::set(const char*, Value& v, SnortConfig* sc)
 
 static const Parameter active_params[] =
 {
-    { "attempts", Parameter::PT_INT, "0:20", "0",
+    { "attempts", Parameter::PT_INT, "0:255", "0",
       "number of TCP packets sent per response (with varying sequence numbers)" },
 
     { "device", Parameter::PT_STRING, nullptr, nullptr,
@@ -858,7 +858,7 @@ static const Parameter active_params[] =
     { "dst_mac", Parameter::PT_STRING, nullptr, nullptr,
       "use format '01:23:45:67:89:ab'" },
 
-    { "max_responses", Parameter::PT_INT, "0:", "0",
+    { "max_responses", Parameter::PT_INT, "0:255", "0",
       "maximum number of responses" },
 
     { "min_interval", Parameter::PT_INT, "1:255", "255",
@@ -895,7 +895,7 @@ public:
 bool ActiveModule::set(const char*, Value& v, SnortConfig* sc)
 {
     if ( v.is("attempts") )
-        sc->respond_attempts = v.get_long();
+        sc->respond_attempts = v.get_uint8();
 
     else if ( v.is("device") )
         sc->respond_device = v.get_string();
@@ -904,10 +904,10 @@ bool ActiveModule::set(const char*, Value& v, SnortConfig* sc)
         sc->set_dst_mac(v.get_string());
 
     else if ( v.is("max_responses") )
-        sc->max_responses = v.get_long();
+        sc->max_responses = v.get_uint8();
 
     else if ( v.is("min_interval") )
-        sc->min_interval = v.get_long();
+        sc->min_interval = v.get_uint8();
 
     else
         return false;
@@ -927,10 +927,10 @@ static const Parameter packets_params[] =
     { "bpf_file", Parameter::PT_STRING, nullptr, nullptr,
       "file with BPF to select traffic for Snort" },
 
-    { "limit", Parameter::PT_INT, "0:", "0",
+    { "limit", Parameter::PT_INT, "0:max53", "0",
       "maximum number of packets to process before stopping (0 is unlimited)" },
 
-    { "skip", Parameter::PT_INT, "0:", "0",
+    { "skip", Parameter::PT_INT, "0:max53", "0",
       "number of packets to skip before before processing" },
 
     { "vlan_agnostic", Parameter::PT_BOOL, nullptr, "false",
@@ -955,19 +955,19 @@ public:
 bool PacketsModule::set(const char*, Value& v, SnortConfig* sc)
 {
     if ( v.is("address_space_agnostic") )
-        sc->addressspace_agnostic = v.get_long();
+        sc->addressspace_agnostic = v.get_bool();
 
     else if ( v.is("bpf_file") )
         sc->bpf_file = v.get_string();
 
     else if ( v.is("limit") )
-        sc->pkt_cnt = v.get_long();
+        sc->pkt_cnt = v.get_uint64();
 
     else if ( v.is("skip") )
-        sc->pkt_skip = v.get_long();
+        sc->pkt_skip = v.get_uint64();
 
     else if ( v.is("vlan_agnostic") )
-        sc->vlan_agnostic = v.get_long();
+        sc->vlan_agnostic = v.get_bool();
 
     else
         return false;
@@ -982,14 +982,14 @@ bool PacketsModule::set(const char*, Value& v, SnortConfig* sc)
 
 static const Parameter attribute_table_params[] =
 {
-    { "max_hosts", Parameter::PT_INT, "32:207551", "1024",
+    { "max_hosts", Parameter::PT_INT, "32:max53", "1024",
       "maximum number of hosts in attribute table" },
 
     { "max_services_per_host", Parameter::PT_INT, "1:65535", "8",
       "maximum number of services per host entry in attribute table" },
 
-    { "max_metadata_services", Parameter::PT_INT, "1:256", "8",
-      "maximum number of services in rule metadata" },
+    { "max_metadata_services", Parameter::PT_INT, "1:255", "8",
+      "maximum number of services in rule" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
@@ -1011,13 +1011,13 @@ public:
 bool AttributeTableModule::set(const char*, Value& v, SnortConfig* sc)
 {
     if ( v.is("max_hosts") )
-        sc->max_attribute_hosts = v.get_long();
+        sc->max_attribute_hosts = v.get_uint32();
 
     else if ( v.is("max_services_per_host") )
-        sc->max_attribute_services_per_host = v.get_long();
+        sc->max_attribute_services_per_host = v.get_uint16();
 
     else if ( v.is("max_metadata_services") )
-        sc->max_metadata_services = v.get_long();
+        sc->max_metadata_services = v.get_uint8();
 
     else
         return false;
@@ -1094,24 +1094,24 @@ bool NetworkModule::set(const char*, Value& v, SnortConfig* sc)
 
     else if ( v.is("id") )
     {
-        p->user_policy_id = v.get_long();
+        p->user_policy_id = v.get_uint16();
         sc->policy_map->set_user_network(p);
     }
 
     else if ( v.is("min_ttl") )
-        p->min_ttl = (uint8_t)v.get_long();
+        p->min_ttl = v.get_uint8();
 
     else if ( v.is("new_ttl") )
-        p->new_ttl = (uint8_t)v.get_long();
+        p->new_ttl = v.get_uint8();
 
     else if (v.is("layers"))
-        sc->num_layers = (uint8_t)v.get_long();
+        sc->num_layers = v.get_uint8();
 
     else if (v.is("max_ip6_extensions"))
-        sc->max_ip6_extensions = (uint8_t)v.get_long();
+        sc->max_ip6_extensions = v.get_uint8();
 
     else if (v.is("max_ip_layers"))
-        sc->max_ip_layers = (uint8_t)v.get_long();
+        sc->max_ip_layers = v.get_uint8();
 
     else
         return false;
@@ -1158,7 +1158,7 @@ bool InspectionModule::set(const char*, Value& v, SnortConfig* sc)
 
     if ( v.is("id") )
     {
-        p->user_policy_id = v.get_long();
+        p->user_policy_id = v.get_uint16();
         sc->policy_map->set_user_inspection(p);
     }
 
@@ -1175,7 +1175,7 @@ bool InspectionModule::set(const char*, Value& v, SnortConfig* sc)
 
     else if ( v.is("mode") )
     {
-        switch ( v.get_long() )
+        switch ( v.get_uint8() )
         {
             case 0:
                 p->policy_mode = POLICY_MODE__INLINE;
@@ -1245,7 +1245,7 @@ bool IpsModule::set(const char*, Value& v, SnortConfig* sc)
 
     else if ( v.is("id") )
     {
-        p->user_policy_id = v.get_long();
+        p->user_policy_id = v.get_uint16();
         sc->policy_map->set_user_ips(p);
     }
 
@@ -1253,7 +1253,7 @@ bool IpsModule::set(const char*, Value& v, SnortConfig* sc)
         p->include = v.get_string();
 
     else if ( v.is("mode") )
-        p->policy_mode = (PolicyMode)v.get_long();
+        p->policy_mode = (PolicyMode)v.get_uint8();
 
     else if ( v.is("rules") )
         p->rules = v.get_string();
@@ -1284,7 +1284,7 @@ static const Parameter thread_pinning_params[] =
     { "cpuset", Parameter::PT_STRING, nullptr, nullptr,
       "pin the associated thread to this cpuset" },
 
-    { "thread", Parameter::PT_INT, "0:", "0",
+    { "thread", Parameter::PT_INT, "0:65535", "0",
       "set cpu affinity for the <cur_thread_num> thread that runs" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -1310,7 +1310,7 @@ static const Parameter process_params[] =
     { "set_uid", Parameter::PT_STRING, nullptr, nullptr,
       "set user ID (same as -u)" },
 
-    { "umask", Parameter::PT_STRING, nullptr, nullptr,
+    { "umask", Parameter::PT_INT, "0x000:0x1FF", nullptr,
       "set process umask (same as -m)" },
 
     { "utc", Parameter::PT_BOOL, nullptr, "false",
@@ -1356,7 +1356,7 @@ bool ProcessModule::set(const char*, Value& v, SnortConfig* sc)
         sc->set_uid(v.get_string());
 
     else if ( v.is("umask") )
-        sc->set_umask(v.get_string());
+        sc->set_umask(v.get_uint32());
 
     else if ( v.is("utc") )
         sc->set_utc(v.get_bool());
@@ -1367,7 +1367,7 @@ bool ProcessModule::set(const char*, Value& v, SnortConfig* sc)
             return false;
     }
     else if (v.is("thread"))
-        thread = v.get_long();
+        thread = v.get_uint16();
 
     else
         return false;
@@ -1413,10 +1413,10 @@ bool ProcessModule::end(const char* fqn, int idx, SnortConfig* sc)
 
 static const Parameter suppress_params[] =
 {
-    { "gid", Parameter::PT_INT, "0:", "0",
+    { "gid", Parameter::PT_INT, "0:max32", "0",
       "rule generator ID" },
 
-    { "sid", Parameter::PT_INT, "0:", "0",
+    { "sid", Parameter::PT_INT, "0:max32", "0",
       "rule signature ID" },
 
     { "track", Parameter::PT_ENUM, "by_src | by_dst", nullptr,
@@ -1449,13 +1449,13 @@ private:
 bool SuppressModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("gid") )
-        thdx.gen_id = v.get_long();
+        thdx.gen_id = v.get_uint32();
 
     else if ( v.is("sid") )
-        thdx.sig_id = v.get_long();
+        thdx.sig_id = v.get_uint32();
 
     else if ( v.is("track") )
-        thdx.tracking = v.get_long() + 1;
+        thdx.tracking = v.get_uint8() + 1;
 
     else if ( v.is("ip") )
         thdx.ip_address = sfip_var_from_string(v.get_string(), "suppress");
@@ -1491,10 +1491,10 @@ bool SuppressModule::end(const char*, int idx, SnortConfig* sc)
 
 static const Parameter event_filter_params[] =
 {
-    { "gid", Parameter::PT_INT, "0:", "1",
+    { "gid", Parameter::PT_INT, "0:max32", "1",
       "rule generator ID" },
 
-    { "sid", Parameter::PT_INT, "0:", "1",
+    { "sid", Parameter::PT_INT, "0:max32", "1",
       "rule signature ID" },
 
     { "type", Parameter::PT_ENUM, "limit | threshold | both", nullptr,
@@ -1503,10 +1503,10 @@ static const Parameter event_filter_params[] =
     { "track", Parameter::PT_ENUM, "by_src | by_dst", nullptr,
       "filter only matching source or destination addresses" },
 
-    { "count", Parameter::PT_INT, "-1:", "0",
+    { "count", Parameter::PT_INT, "-1:max31", "0",
       "number of events in interval before tripping; -1 to disable" },
 
-    { "seconds", Parameter::PT_INT, "0:", "0",
+    { "seconds", Parameter::PT_INT, "0:max32", "0",
       "count interval" },
 
     { "ip", Parameter::PT_STRING, nullptr, nullptr,
@@ -1537,25 +1537,25 @@ private:
 bool EventFilterModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("gid") )
-        thdx.gen_id = v.get_long();
+        thdx.gen_id = v.get_uint32();
 
     else if ( v.is("sid") )
-        thdx.sig_id = v.get_long();
+        thdx.sig_id = v.get_uint32();
 
     else if ( v.is("track") )
-        thdx.tracking = v.get_long() + 1;
+        thdx.tracking = v.get_uint8() + 1;
 
     else if ( v.is("ip") )
         thdx.ip_address = sfip_var_from_string(v.get_string(), "event_filter");
 
     else if ( v.is("count") )
-        thdx.count = v.get_long();
+        thdx.count = v.get_int32();
 
     else if ( v.is("seconds") )
-        thdx.seconds = v.get_long();
+        thdx.seconds = v.get_uint32();
 
     else if ( v.is("type") )
-        thdx.type = v.get_long();
+        thdx.type = v.get_uint8();
 
     else
         return false;
@@ -1587,19 +1587,19 @@ bool EventFilterModule::end(const char*, int idx, SnortConfig* sc)
 
 static const Parameter rate_filter_params[] =
 {
-    { "gid", Parameter::PT_INT, "0:", "1",
+    { "gid", Parameter::PT_INT, "0:max32", "1",
       "rule generator ID" },
 
-    { "sid", Parameter::PT_INT, "0:", "1",
+    { "sid", Parameter::PT_INT, "0:max32", "1",
       "rule signature ID" },
 
     { "track", Parameter::PT_ENUM, "by_src | by_dst | by_rule", "by_src",
       "filter only matching source or destination addresses" },
 
-    { "count", Parameter::PT_INT, "0:", "1",
+    { "count", Parameter::PT_INT, "0:max32", "1",
       "number of events in interval before tripping" },
 
-    { "seconds", Parameter::PT_INT, "0:", "1",
+    { "seconds", Parameter::PT_INT, "0:max32", "1",
       "count interval" },
 
     { "new_action", Parameter::PT_ENUM,
@@ -1608,7 +1608,7 @@ static const Parameter rate_filter_params[] =
       "log | pass | alert | drop | block | reset", "alert",
       "take this action on future hits until timeout" },
 
-    { "timeout", Parameter::PT_INT, "0:", "1",
+    { "timeout", Parameter::PT_INT, "0:max32", "1",
       "count interval" },
 
     { "apply_to", Parameter::PT_STRING, nullptr, nullptr,
@@ -1646,28 +1646,28 @@ RateFilterModule::~RateFilterModule()
 bool RateFilterModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("gid") )
-        thdx.gid = v.get_long();
+        thdx.gid = v.get_uint32();
 
     else if ( v.is("sid") )
-        thdx.sid = v.get_long();
+        thdx.sid = v.get_uint32();
 
     else if ( v.is("track") )
-        thdx.tracking = (SFRF_TRACK)(v.get_long() + 1);
+        thdx.tracking = (SFRF_TRACK)(v.get_uint8() + 1);
 
     else if ( v.is("count") )
-        thdx.count = v.get_long();
+        thdx.count = v.get_uint32();
 
     else if ( v.is("seconds") )
-        thdx.seconds = v.get_long();
+        thdx.seconds = v.get_uint32();
 
     else if ( v.is("timeout") )
-        thdx.timeout = v.get_long();
+        thdx.timeout = v.get_uint32();
 
     else if ( v.is("apply_to") )
         thdx.applyTo = sfip_var_from_string(v.get_string(), "rate_filter");
 
     else if ( v.is("new_action") )
-        thdx.newAction = (Actions::Type)(v.get_long() + 1);
+        thdx.newAction = (Actions::Type)(v.get_uint8() + 1);
 
     else
         return false;
@@ -1696,10 +1696,10 @@ bool RateFilterModule::end(const char*, int idx, SnortConfig* sc)
 
 static const Parameter rule_state_params[] =
 {
-    { "gid", Parameter::PT_INT, "0:", "0",
+    { "gid", Parameter::PT_INT, "0:max32", "0",
       "rule generator ID" },
 
-    { "sid", Parameter::PT_INT, "0:", "0",
+    { "sid", Parameter::PT_INT, "0:max32", "0",
       "rule signature ID" },
 
     { "enable", Parameter::PT_BOOL, nullptr, "true",
@@ -1729,10 +1729,10 @@ private:
 bool RuleStateModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("gid") )
-        state.gid = v.get_long();
+        state.gid = v.get_uint32();
 
     else if ( v.is("sid") )
-        state.sid = v.get_long();
+        state.sid = v.get_uint32();
 
     else if ( v.is("enable") )
         state.state = v.get_bool();
@@ -1819,10 +1819,10 @@ bool HostsModule::set(const char*, Value& v, SnortConfig* sc)
         v.get_addr(host->ipAddr);
 
     else if ( host and v.is("frag_policy") )
-        host->hostInfo.fragPolicy = v.get_long() + 1;
+        host->hostInfo.fragPolicy = v.get_uint8() + 1;
 
     else if ( host and v.is("tcp_policy") )
-        host->hostInfo.streamPolicy = v.get_long() + 1;
+        host->hostInfo.streamPolicy = v.get_uint8() + 1;
 
     else if ( app and v.is("name") )
         app->snort_protocol_id = sc->proto_ref->add(v.get_string());
@@ -1831,7 +1831,7 @@ bool HostsModule::set(const char*, Value& v, SnortConfig* sc)
         app->ipproto = sc->proto_ref->add(v.get_string());
 
     else if ( app and v.is("port") )
-        app->port = v.get_long();
+        app->port = v.get_uint16();
 
     else
         return false;
index 4423ba06a3f2ddad4f69774b94164f5d077004af..8f48625fa415025f14b0bac74faa848f11c22150 100644 (file)
@@ -869,16 +869,8 @@ void SnortConfig::set_process_all_events(bool enabled)
 # endif
 #endif
 
-void SnortConfig::set_umask(const char* args)
+void SnortConfig::set_umask(uint32_t mask)
 {
-    char* endptr;
-    long mask = SnortStrtol(args, &endptr, 0);
-
-    if ((errno == ERANGE) || (*endptr != '\0') ||
-        (mask < 0) || (mask & ~FILE_ACCESS_BITS))
-    {
-        ParseError("bad umask: %s", args);
-    }
     file_mask = (mode_t)mask;
 }
 
index 861f1de7906d4e759aa96ded9a710e5369067a8f..20c704dca0e937f27f6bf818c9d2b38325347df1 100644 (file)
@@ -191,8 +191,8 @@ public:
 #endif
     uint32_t logging_flags = 0;
 
+    uint32_t tagged_packet_limit = 256;
     uint16_t event_trace_max = 0;
-    long int tagged_packet_limit = 256;
 
     std::string log_dir;
 
@@ -232,16 +232,17 @@ public:
 
     //------------------------------------------------------
     // decode module stuff
-    uint8_t mpls_payload_type = 0;
-    long int mpls_stack_depth = 0;
-
-    uint8_t enable_teredo = 0;
-    uint8_t enable_esp = 0;
     PortBitSet* gtp_ports = nullptr;
 
+    int mpls_stack_depth = 0;
+
+    uint8_t mpls_payload_type = 0;
     uint8_t num_layers = 0;
     uint8_t max_ip6_extensions = 0;
     uint8_t max_ip_layers = 0;
+
+    bool enable_teredo = false;
+    bool enable_esp = false;
     bool address_anomaly_check_enabled = false;
 
     //------------------------------------------------------
@@ -262,8 +263,8 @@ public:
 
     //------------------------------------------------------
     // packet module stuff
-    uint8_t vlan_agnostic = 0;
-    uint8_t addressspace_agnostic = 0;
+    bool vlan_agnostic = false;
+    bool addressspace_agnostic = false;
 
     uint64_t pkt_cnt = 0;           /* -n */
     uint64_t pkt_skip = 0;
@@ -418,7 +419,7 @@ public:
     void set_treat_drop_as_ignore(bool);
     void set_tweaks(const char*);
     void set_uid(const char*);
-    void set_umask(const char*);
+    void set_umask(uint32_t);
     void set_utc(bool);
     void set_verbose(bool);
     void free_rule_state_list();
index 8393460535c47afffd82bf6c569b62212f714d37..5da96c3ed39bbda299ff51bb207945f824d10be6 100644 (file)
@@ -79,7 +79,7 @@ static const Parameter s_module[] =
 
 static const Parameter s_pktnum[] =
 {
-    { "pkt_num", Parameter::PT_INT, "1:", nullptr,
+    { "pkt_num", Parameter::PT_INT, "1:max53", nullptr,
       "resume and pause after pkt_num packets" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -88,7 +88,10 @@ static const Parameter s_pktnum[] =
 static const Command snort_cmds[] =
 {
     { "show_plugins", main_dump_plugins, nullptr, "show available plugins" },
-    { "delete_inspector", main_delete_inspector, s_delete, "delete an inspector from the default policy" },
+
+    { "delete_inspector", main_delete_inspector, s_delete,
+      "delete an inspector from the default policy" },
+
     { "dump_stats", main_dump_stats, nullptr, "show summary statistics" },
     { "rotate_stats", main_rotate_stats, nullptr, "roll perfmonitor log files" },
     { "reload_config", main_reload_config, s_reload, "load new configuration" },
@@ -101,8 +104,10 @@ static const Command snort_cmds[] =
     //{ "process", main_process, nullptr, "process given pcap" },
 
     { "pause", main_pause, nullptr, "suspend packet processing" },
+
     { "resume", main_resume, s_pktnum, "continue packet processing. "
       "If number of packet is specified, will resume for n packets and pause" },
+
     { "detach", main_detach, nullptr, "exit shell w/o shutdown" },
     { "quit", main_quit, nullptr, "shutdown and dump-stats" },
     { "help", main_help, nullptr, "this output" },
@@ -121,7 +126,7 @@ static const Command snort_cmds[] =
     exit(0);
 }
 
-[[noreturn]] static void x2c(unsigned x)
+[[noreturn]] static void x2c(uint8_t x)
 {
     printf("0x%2.2X (%u) = '%c'\n", x, x, static_cast<char>(x));
     exit(0);
@@ -220,10 +225,10 @@ static const Parameter s_params[] =
     { "-M", Parameter::PT_IMPLIED, nullptr, nullptr,
       "log messages to syslog (not alerts)" },
 
-    { "-m", Parameter::PT_INT, "0:", nullptr,
-      "<umask> set umask = <umask>" },
+    { "-m", Parameter::PT_INT, "0x000:0x1FF", nullptr,
+      "<umask> set the process file mode creation mask" },
 
-    { "-n", Parameter::PT_INT, "0:", nullptr,
+    { "-n", Parameter::PT_INT, "0:max53", nullptr,
       "<count> stop after count packets" },
 
     { "-O", Parameter::PT_IMPLIED, nullptr, nullptr,
@@ -274,7 +279,7 @@ static const Parameter s_params[] =
     { "-y", Parameter::PT_IMPLIED, nullptr, nullptr,
       "include year in timestamp in the alert and log files" },
 
-    { "-z", Parameter::PT_INT, "0:", "1",
+    { "-z", Parameter::PT_INT, "0:max32", "1",
       "<count> maximum number of packet threads (same as --max-packet-threads); "
       "0 gets the number of CPU cores reported by the system; default is 1" },
 
@@ -342,6 +347,9 @@ static const Parameter s_params[] =
     { "--help-counts", Parameter::PT_STRING, "(optional)", nullptr,
       "[<module prefix>] output matching peg counts" },
 
+    { "--help-limits", Parameter::PT_IMPLIED, nullptr, nullptr,
+      "print the int upper bounds denoted by max*" },
+
     { "--help-module", Parameter::PT_STRING, nullptr, nullptr,
       "<module> output description of given module" },
 
@@ -390,7 +398,7 @@ static const Parameter s_params[] =
     { "--markup", Parameter::PT_IMPLIED, nullptr, nullptr,
       "output help in asciidoc compatible format" },
 
-    { "--max-packet-threads", Parameter::PT_INT, "0:", "1",
+    { "--max-packet-threads", Parameter::PT_INT, "0:max32", "1",
       "<count> configure maximum number of packet threads (same as -z)" },
 
     { "--mem-check", Parameter::PT_IMPLIED, nullptr, nullptr,
@@ -406,7 +414,7 @@ static const Parameter s_params[] =
       "wait for resume/quit command before processing packets/terminating", },
 
 #ifdef REG_TEST
-    { "--pause-after-n", Parameter::PT_INT, "1:", nullptr,
+    { "--pause-after-n", Parameter::PT_INT, "1:max53", nullptr,
       "<count> pause after count packets", },
 #endif
 
@@ -425,7 +433,7 @@ static const Parameter s_params[] =
     { "--pcap-filter", Parameter::PT_STRING, nullptr, nullptr,
       "<filter> filter to apply when getting pcaps from file or directory" },
 
-    { "--pcap-loop", Parameter::PT_INT, "-1:", nullptr,
+    { "--pcap-loop", Parameter::PT_INT, "0:max32", nullptr,
       "<count> read all pcaps <count> times;  0 will read until Snort is terminated" },
 
     { "--pcap-no-filter", Parameter::PT_IMPLIED, nullptr, nullptr,
@@ -478,7 +486,7 @@ static const Parameter s_params[] =
     { "--show-plugins", Parameter::PT_IMPLIED, nullptr, nullptr,
       "list module and plugin versions", },
 
-    { "--skip", Parameter::PT_INT, "0:", nullptr,
+    { "--skip", Parameter::PT_INT, "0:max53", nullptr,
       "<n> skip 1st n packets", },
 
     { "--snaplen", Parameter::PT_INT, "68:65535", "1518",
@@ -536,7 +544,7 @@ static const Parameter s_params[] =
     { "--warn-vars", Parameter::PT_IMPLIED, nullptr, nullptr,
       "warn about variable definition and usage issues" },
 
-    { "--x2c", Parameter::PT_INT, nullptr, nullptr,
+    { "--x2c", Parameter::PT_INT, "0x00:0xFF", nullptr,
       "output ASCII char for given hex (see also --c2x)" },
 
     { "--x2s", Parameter::PT_STRING, nullptr, nullptr,
@@ -634,7 +642,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         sc->output_flags |= OUTPUT_FLAG__LINE_BUFFER;
 
     else if ( v.is("-G") || v.is("--logid") )
-        sc->event_log_id = v.get_long() << 16;
+        sc->event_log_id = v.get_uint16() << 16;
 
     else if ( v.is("-g") )
         sc->set_gid(v.get_string());
@@ -654,7 +662,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
 #ifdef SHELL
     else if ( v.is("-j") )
     {
-        sc->remote_control_port = v.get_long();
+        sc->remote_control_port = v.get_uint16();
         sc->remote_control_socket.clear();
     }
 #endif
@@ -672,10 +680,10 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         sc->enable_syslog();
 
     else if ( v.is("-m") )
-        sc->set_umask(v.get_string());
+        sc->set_umask(v.get_uint32());
 
     else if ( v.is("-n") )
-        sc->pkt_cnt = v.get_long();
+        sc->pkt_cnt = v.get_uint64();
 
     else if ( v.is("-O") )
         sc->set_obfuscate(true);
@@ -700,8 +708,8 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
     else if ( v.is("-S") )
         config_set_var(sc, v.get_string());
 
-    else if ( v.is("-s") )
-        sc->daq_config->set_mru_size(v.get_long());
+    else if ( v.is("-s") or v.is("--snaplen") )
+        sc->daq_config->set_mru_size(v.get_uint16());
 
     else if ( v.is("-T") )
         sc->run_flags |= RUN_FLAG__TEST;
@@ -731,7 +739,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         sc->set_show_year(true);
 
     else if ( v.is("-z") || v.is("--max-packet-threads") )
-        ThreadConfig::set_instance_max(v.get_long());
+        ThreadConfig::set_instance_max(v.get_uint32());
 
     else if ( v.is("--alert-before-pass") )
         sc->set_alert_before_pass(true);
@@ -807,6 +815,9 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
     else if ( v.is("--help-counts") )
         help_counts(sc, v.get_string());
 
+    else if ( v.is("--help-limits") )
+        help_limits(sc, v.get_string());
+
     else if ( v.is("--help-module") )
         help_module(sc, v.get_string());
 
@@ -823,7 +834,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         help_signals(sc, v.get_string());
 
     else if ( v.is("--id-offset") )
-        sc->id_offset = v.get_long();
+        sc->id_offset = v.get_uint16();
 
     else if ( v.is("--id-subdir") )
         sc->id_subdir = true;
@@ -866,7 +877,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
 
 #ifdef REG_TEST
     else if ( v.is("--pause-after-n") )
-        sc->pkt_pause_cnt = v.get_long();
+        sc->pkt_pause_cnt = v.get_uint64();
 #endif
 
     else if ( v.is("--parsing-follows-files") )
@@ -886,7 +897,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         Trough::set_filter(v.get_string());
 
     else if ( v.is("--pcap-loop") )
-        Trough::set_loop_count(v.get_long());
+        Trough::set_loop_count(v.get_uint32());
 
     else if ( v.is("--pcap-no-filter") )
         Trough::set_filter(nullptr);
@@ -935,10 +946,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         sc->logging_flags |= LOGGING_FLAG__SHOW_PLUGINS;
 
     else if ( v.is("--skip") )
-        sc->pkt_skip = v.get_long();
-
-    else if ( v.is("--snaplen") )
-        sc->daq_config->set_mru_size(v.get_long());
+        sc->pkt_skip = v.get_uint64();
 
     else if ( v.is("--stdin-rules") )
         sc->stdin_rules = true;
@@ -996,7 +1004,7 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
         sc->warning_flags |= (1 << WARN_VARS);
 
     else if ( v.is("--x2c") )
-        x2c(v.get_long());
+        x2c(v.get_uint8());
 
     else if ( v.is("--x2s") )
         x2s(v.get_string());
index cd7261100b2c8cd2debac71a1ab5d1c290e79b03..a64a6e09ebea5ed420a9a4de0c16824ae407de58 100644 (file)
@@ -119,7 +119,7 @@ static bool set_arg(
         if ( p->is_wild_card() )
             val = opt;
 
-        long n = strtol(val, &end, 0);
+        long n = (long)strtod(val, &end);
 
         if ( !*end )
             v.set(n);
index bb08afa74d9fa2331823bd4b5b42fabce173a41a..40b88620f6162bfeef1d925835a24482c3dba704 100644 (file)
@@ -174,7 +174,7 @@ static void trace(const char* s, const char* fqn, Value& v)
     if ( v.get_type() == Value::VT_STR )
         printf("%s: %s = '%s'\n", s, fqn, v.get_string());
     else
-        printf("%s: %s = %ld\n", s, fqn, v.get_long());
+        printf("%s: %s = " STDi64 "\n", s, fqn, v.get_int64());
 }
 
 static ModHook* get_hook(const char* s)
@@ -507,8 +507,8 @@ static bool set_value(const char* fqn, Value& v)
 
     if ( v.get_type() == Value::VT_STR )
         ParseError("invalid %s = '%s'", fqn, v.get_string());
-    else if ( v.get_real() == v.get_long() )
-        ParseError("invalid %s = %ld", fqn, v.get_long());
+    else if ( v.get_real() == v.get_int64() )
+        ParseError("invalid %s = " STDi64, fqn, v.get_int64());
     else
         ParseError("invalid %s = %g", fqn, v.get_real());
 
index 57a88015878b9b3fd490070b1cdbb9c5921496eb..b2cdd864ae1e84b7d13fd7bde6d4405a1432eb5d 100644 (file)
@@ -99,8 +99,10 @@ Mpse* MpseManager::get_search_engine(
 
 Mpse* MpseManager::get_search_engine(const char* type)
 {
-    if ( !type and SnortConfig::get_conf()->fast_pattern_config )
-        type = SnortConfig::get_conf()->fast_pattern_config->get_search_method();
+    SnortConfig* sc = SnortConfig::get_conf();
+
+    if ( !type and sc->fast_pattern_config )
+        type = sc->fast_pattern_config->get_search_method();
 
     if ( !type )
         type = "ac_bnfa";
@@ -114,7 +116,7 @@ Mpse* MpseManager::get_search_engine(const char* type)
     Mpse* eng = api->ctor(nullptr, mod, nullptr);
     eng->set_api(api);
 
-    if ( SnortConfig::get_conf()->fast_pattern_config and SnortConfig::get_conf()->fast_pattern_config->get_search_opt() )
+    if ( sc->fast_pattern_config and sc->fast_pattern_config->get_search_opt() )
         eng->set_opt(1);
 
     return eng;
index ec8ca29d913dbfac6d7e09edbfa2cf9f5676f350..4aa09df9eacc6414a3dfc5ea62f28125d915f068 100644 (file)
@@ -214,7 +214,7 @@ void MemoryCap::print()
     if ( snort::SnortConfig::log_verbose() )
     {
         LogMessage("    global cap: %zu\n", config.cap);
-        LogMessage("    global preemptive threshold percent: %zu\n", config.threshold);
+        LogMessage("    global preemptive threshold percent: %u\n", config.threshold);
         LogMessage("    cap type: %s\n", config.soft? "soft" : "hard");
     }
 
index ea752ff75b7275e4b5c43b35146060cd0aaacc78..8208ec94a1d8e8f4491a2341b1b61276b1df8ba2 100644 (file)
@@ -26,8 +26,8 @@
 struct MemoryConfig
 {
     size_t cap = 0;
+    unsigned threshold = 0;
     bool soft = false;
-    size_t threshold = 0;
 
     constexpr MemoryConfig() = default;
 };
index 380f554f6769307f88ab8bf92bb8df7fd4cdc16e..c89cea5c7310c5b66ca39277a8e70d074813f2d1 100644 (file)
@@ -40,13 +40,13 @@ using namespace snort;
 
 static const Parameter s_params[] =
 {
-    { "cap", Parameter::PT_INT, "0:", "0",
+    { "cap", Parameter::PT_INT, "0:maxSZ", "0",
         "set the per-packet-thread cap on memory (bytes, 0 to disable)" },
 
     { "soft", Parameter::PT_BOOL, nullptr, "false",
         "always succeed in allocating memory, even if above the cap" },
 
-    { "threshold", Parameter::PT_INT, "0:", "0",
+    { "threshold", Parameter::PT_INT, "0:100", "0",
         "set the per-packet-thread threshold for preemptive cleanup actions "
         "(percent, 0 to disable)" },
 
@@ -66,13 +66,13 @@ MemoryModule::MemoryModule() :
 bool MemoryModule::set(const char*, Value& v, SnortConfig* sc)
 {
     if ( v.is("cap") )
-        sc->memory->cap = v.get_long();
+        sc->memory->cap = v.get_size();
 
     else if ( v.is("soft") )
         sc->memory->soft = v.get_bool();
 
     else if ( v.is("threshold") )
-        sc->memory->threshold = v.get_long();
+        sc->memory->threshold = v.get_uint8();
 
     else
         return false;
index 4865dadb63d8c42df4863f27e7dc548ed713de5e..ac7ee4c7bc2af034e0b87ac2e8df1a47f21e21dd 100644 (file)
@@ -81,7 +81,7 @@ public:
     bool tp_appid_stats_enable = false;
     bool tp_appid_config_dump = false;
     uint32_t instance_id = 0;
-    uint32_t memcap = 0;
+    size_t memcap = 0;
     bool debug = false;
     bool dump_ports = false;
     bool log_all_sessions = false;
index d3a4526570ba120c35c10dd0cb59234b84ff07d1..6fbbb2bd7723b28f35bd46ea0f996aa6a83b8e36 100644 (file)
@@ -57,22 +57,22 @@ static const Parameter s_params[] =
 #endif
     // FIXIT-L: DECRYPT_DEBUG - Move this to ssl-module
 #ifdef REG_TEST
-    { "first_decrypted_packet_debug", Parameter::PT_INT, "0:", "0",
+    { "first_decrypted_packet_debug", Parameter::PT_INT, "0:max32", "0",
       "the first packet of an already decrypted SSL flow (debug single session only)" },
 #endif
-    { "memcap", Parameter::PT_INT, "0:", "0",
+    { "memcap", Parameter::PT_INT, "0:maxSZ", "0",
       "disregard - not implemented" },  // FIXIT-M implement or delete appid.memcap
     { "log_stats", Parameter::PT_BOOL, nullptr, "false",
       "enable logging of appid statistics" },
-    { "app_stats_period", Parameter::PT_INT, "0:", "300",
+    { "app_stats_period", Parameter::PT_INT, "0:max32", "300",
       "time period for collecting and logging appid statistics" },
-    { "app_stats_rollover_size", Parameter::PT_INT, "0:", "20971520",
+    { "app_stats_rollover_size", Parameter::PT_INT, "0:max32", "20971520",
       "max file size for appid stats before rolling over the log file" },
-    { "app_stats_rollover_time", Parameter::PT_INT, "0:", "86400",
+    { "app_stats_rollover_time", Parameter::PT_INT, "0:max31", "86400",
       "max time period for collection appid stats before rolling over the log file" },
     { "app_detector_dir", Parameter::PT_STRING, nullptr, nullptr,
       "directory to load appid detectors from" },
-    { "instance_id", Parameter::PT_INT, "0:", "0",
+    { "instance_id", Parameter::PT_INT, "0:max32", "0",
       "instance id - ignored" },
     { "debug", Parameter::PT_BOOL, nullptr, "false",
       "enable appid debug logging" },
@@ -227,19 +227,19 @@ bool AppIdModule::set(const char* fqn, Value& v, SnortConfig* c)
     // FIXIT-L: DECRYPT_DEBUG - Move this to ssl-module
 #ifdef REG_TEST
     if ( v.is("first_decrypted_packet_debug") )
-        config->first_decrypted_packet_debug = v.get_long();
+        config->first_decrypted_packet_debug = v.get_uint32();
     else
 #endif
     if ( v.is("memcap") )
-        config->memcap = v.get_long();
+        config->memcap = v.get_size();
     else if ( v.is("log_stats") )
         config->stats_logging_enabled = v.get_bool();
     else if ( v.is("app_stats_period") )
-        config->app_stats_period = v.get_long();
+        config->app_stats_period = v.get_uint32();
     else if ( v.is("app_stats_rollover_size") )
-        config->app_stats_rollover_size = v.get_long();
+        config->app_stats_rollover_size = v.get_uint32();
     else if ( v.is("app_stats_rollover_time") )
-        config->app_stats_rollover_time = v.get_long();
+        config->app_stats_rollover_time = v.get_uint32();
     else if ( v.is("app_detector_dir") )
         config->app_detector_dir = snort_strdup(v.get_string());
     else if ( v.is("tp_appid_path") )
@@ -251,7 +251,7 @@ bool AppIdModule::set(const char* fqn, Value& v, SnortConfig* c)
     else if ( v.is("tp_appid_config_dump") )
         config->tp_appid_config_dump = v.get_bool();
     else if ( v.is("instance_id") )
-        config->instance_id = v.get_long();
+        config->instance_id = v.get_uint32();
     else if ( v.is("debug") )
         config->debug = v.get_bool();
     else if ( v.is("dump_ports") )
index cc9ef9c53cce4ce8b64653a7995d3bc0b65d4492..b78547df5e450408c8318dfa039303ba5389cc67 100644 (file)
@@ -166,7 +166,8 @@ void AppIdStatistics::dump_statistics()
                     app_name = tmpBuff;
                 }
 
-                TextLog_Print(log, "%lu,%s,%lu,%lu\n",
+                // FIXIT-M %lu won't do time_t on 32-bit systems
+                TextLog_Print(log, "%lu,%s," STDu64 "," STDu64 "\n",
                     packet_time(), app_name, record->initiatorBytes, record->responderBytes);
             }
         }
index 08a2a8aae86674e4ad3c4fa6aec7241c04595f14..ba69c530b2d72e00fe0ed3bed4830d77a075c10f 100644 (file)
@@ -57,7 +57,7 @@ enum TPSessionAttr
 };
 
 #define TPAD_GET(func)                                          \
-    string* func(bool caller_owns_it = 0)                       \
+    string* func(bool caller_owns_it = false)                   \
     {                                                           \
         string* tmp = func ## _buf;                             \
         if (caller_owns_it)                                     \
index 115fff16e6e274413d8ff3d1d75d0a0ff12a051a..d6676d13071f90cfc69d7c14d3a213e3f3b0a4cd 100644 (file)
@@ -54,13 +54,12 @@ static const PegInfo bind_pegs[] =
 // binder module
 //-------------------------------------------------------------------------
 
-#define INT32_MAX_STR "2147483647"
 static const Parameter binder_when_params[] =
 {
     // FIXIT-L when.policy_id should be an arbitrary string auto converted
     // into index for binder matching and lookups
 
-    { "ips_policy_id", Parameter::PT_INT, "0:", "0",
+    { "ips_policy_id", Parameter::PT_INT, "0:max32", "0",
       "unique ID for selection of this config by external logic" },
 
     { "ifaces", Parameter::PT_BIT_LIST, "255", nullptr,
@@ -90,10 +89,10 @@ static const Parameter binder_when_params[] =
     { "dst_ports", Parameter::PT_BIT_LIST, "65535", nullptr,
       "list of destination ports" },
 
-    { "src_zone", Parameter::PT_INT, "0:" INT32_MAX_STR, nullptr,
+    { "src_zone", Parameter::PT_INT, "0:max31", nullptr,
       "source zone" },
 
-    { "dst_zone", Parameter::PT_INT, "0:" INT32_MAX_STR, nullptr,
+    { "dst_zone", Parameter::PT_INT, "0:max31", nullptr,
       "destination zone" },
 
     { "role", Parameter::PT_ENUM, "client | server | any", "any",
@@ -204,7 +203,7 @@ bool BinderModule::set(const char* fqn, Value& v, SnortConfig*)
         work->when.split_nets = true;
     }
     else if ( v.is("ips_policy_id") )
-        work->when.ips_id = v.get_long();
+        work->when.ips_id = v.get_uint32();
 
     else if ( v.is("proto") )
     {
@@ -213,7 +212,7 @@ bool BinderModule::set(const char* fqn, Value& v, SnortConfig*)
             PROTO_BIT__ANY_TYPE, PROTO_BIT__IP, PROTO_BIT__ICMP,
             PROTO_BIT__TCP, PROTO_BIT__UDP, PROTO_BIT__PDU, PROTO_BIT__FILE
         };
-        work->when.protos = mask[v.get_long()];
+        work->when.protos = mask[v.get_uint8()];
     }
     else if ( v.is("ports") )
     {
@@ -232,20 +231,20 @@ bool BinderModule::set(const char* fqn, Value& v, SnortConfig*)
     }
 
     else if ( v.is("src_zone") )
-        work->when.src_zone = v.get_long();
+        work->when.src_zone = v.get_int32();
 
     else if ( v.is("dst_zone") )
-        work->when.dst_zone = v.get_long();
+        work->when.dst_zone = v.get_int32();
 
     else if ( v.is("role") )
-        work->when.role = (BindWhen::Role)v.get_long();
+        work->when.role = (BindWhen::Role)v.get_uint8();
 
     else if ( v.is("vlans") )
         v.get_bits(work->when.vlans);
 
     // use
     else if ( v.is("action") )
-        work->use.action = (BindUse::Action)(v.get_long());
+        work->use.action = (BindUse::Action)(v.get_uint8());
 
     else if ( v.is("file") )
         add_file(v.get_string(), FILE_KEY);
index 28db49bc21880e195a501bceda43d0305f54e1a9..a1b260e3b0ad763c876fe368132b4562c4b52dda 100644 (file)
@@ -52,11 +52,11 @@ static const Parameter s_params[] =
 
 static const Parameter enable_packet_tracer_params[] =
 {
-    {"proto", Parameter::PT_INT, nullptr, nullptr, "numerical IP protocol ID filter"},
+    {"proto", Parameter::PT_INT, "0:255", nullptr, "numerical IP protocol ID filter"},
     {"src_ip", Parameter::PT_STRING, nullptr, nullptr, "source IP address filter"},
-    {"src_port", Parameter::PT_INT, nullptr, nullptr, "source port filter"},
+    {"src_port", Parameter::PT_INT, "0:65535", nullptr, "source port filter"},
     {"dst_ip", Parameter::PT_STRING, nullptr, nullptr, "destination IP address filter"},
-    {"dst_port", Parameter::PT_INT, nullptr, nullptr, "destination port filter"},
+    {"dst_port", Parameter::PT_INT, "0:65535", nullptr, "destination port filter"},
     {nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr}
 };
 
@@ -158,7 +158,7 @@ bool PacketTracerModule::set(const char *, Value &v, SnortConfig*)
 
     else if ( v.is("output") )
     {
-        switch ( v.get_long() )
+        switch ( v.get_uint8() )
         {
             case PACKET_TRACE_CONSOLE:
                 config->file = "-";
index 74f9915b0c5194df5255513be20d2f953d4e547f..79a645feeb95a9d990761f4b9fddd6fcaac7f4cc 100644 (file)
@@ -52,10 +52,10 @@ static const Parameter module_params[] =
 
 static const Parameter s_params[] =
 {
-    { "base", Parameter::PT_BOOL, "nullptr", "true",
+    { "base", Parameter::PT_BOOL, nullptr, "true",
       "enable base statistics" },
 
-    { "cpu", Parameter::PT_BOOL, "nullptr", "false",
+    { "cpu", Parameter::PT_BOOL, nullptr, "false",
       "enable cpu statistics" },
 
     { "flow", Parameter::PT_BOOL, nullptr, "false",
@@ -64,16 +64,16 @@ static const Parameter s_params[] =
     { "flow_ip", Parameter::PT_BOOL, nullptr, "false",
       "enable statistics on host pairs" },
 
-    { "packets", Parameter::PT_INT, "0:", "10000",
+    { "packets", Parameter::PT_INT, "0:max32", "10000",
       "minimum packets to report" },
 
-    { "seconds", Parameter::PT_INT, "1:", "60",
+    { "seconds", Parameter::PT_INT, "1:max32", "60",
       "report interval" },
 
-    { "flow_ip_memcap", Parameter::PT_INT, "8200:", "52428800",
+    { "flow_ip_memcap", Parameter::PT_INT, "8200:maxSZ", "52428800",
       "maximum memory in bytes for flow tracking" },
 
-    { "max_file_size", Parameter::PT_INT, "4096:", "1073741824",
+    { "max_file_size", Parameter::PT_INT, "4096:max53", "1073741824",
       "files will be rolled over if they exceed this size" },
 
     { "flow_ports", Parameter::PT_INT, "0:65535", "1023",
@@ -138,32 +138,32 @@ bool PerfMonModule::set(const char*, Value& v, SnortConfig*)
     }
     else if ( v.is("packets") )
     {
-        config->pkt_cnt = v.get_long();
+        config->pkt_cnt = v.get_uint32();
     }
     else if ( v.is("seconds") )
     {
-        config->sample_interval = v.get_long();
+        config->sample_interval = v.get_uint32();
         if ( config->sample_interval == 0 )
             config->perf_flags |= PERF_SUMMARY;
     }
     else if ( v.is("flow_ip_memcap") )
     {
-        config->flowip_memcap = v.get_long();
+        config->flowip_memcap = v.get_size();
     }
     else if ( v.is("max_file_size") )
-        config->max_file_size = v.get_long() - ROLLOVER_THRESH;
+        config->max_file_size = v.get_uint64() - ROLLOVER_THRESH;
 
     else if ( v.is("flow_ports") )
     {
-        config->flow_max_port_to_track = v.get_long();
+        config->flow_max_port_to_track = v.get_uint16();
     }
     else if ( v.is("output") )
     {
-        config->output = (PerfOutput)v.get_long();
+        config->output = (PerfOutput)v.get_uint8();
     }
     else if ( v.is("format") )
     {
-        config->format = (PerfFormat)v.get_long();
+        config->format = (PerfFormat)v.get_uint8();
     }
     else if ( v.is("name") )
     {
index 5442b788e6de45807f5c5faf4f51483800bf4fe6..075ea83d767493129de956788251e596ab7c85ca 100644 (file)
@@ -77,10 +77,10 @@ struct PerfConfig
 {
     int perf_flags = 0;
     uint32_t pkt_cnt = 0;
-    int sample_interval = 0;
+    unsigned sample_interval = 0;
     uint64_t max_file_size = 0;
     int flow_max_port_to_track = 0;
-    uint32_t flowip_memcap = 0;
+    size_t flowip_memcap = 0;
     PerfFormat format = PerfFormat::CSV;
     PerfOutput output = PerfOutput::TO_FILE;
     std::vector<ModuleConfig> modules;
index 3c09d13215a0dfac764bbdd0cdaa29c03a565790..35d9e76073687a1c227f97fc6d8b2cfab3eda874 100644 (file)
@@ -167,7 +167,7 @@ void PerfMonitor::show(SnortConfig*)
         (config->perf_flags & PERF_FLOWIP) ? "ACTIVE" : "INACTIVE");
     if (config->perf_flags & PERF_FLOWIP)
     {
-        LogMessage("    Flow IP Memcap:   %u\n", config->flowip_memcap);
+        LogMessage("    Flow IP Memcap:   %zu\n", config->flowip_memcap);
     }
     LogMessage("  CPU Stats:    %s\n",
         (config->perf_flags & PERF_CPU) ? "ACTIVE" : "INACTIVE");
index b3c56ddc6fef5e9786f79fcadcf66afc43b9294c..3aa8ee8ba3f3afe1af37959d366ab595b61f906c 100644 (file)
@@ -363,8 +363,8 @@ static void PrintPortscanConf(PortscanConfig* config)
         sfsnprintfappend(buf, sizeof(buf)-1, "distributed_portscan");
 
     LogMessage("%s\n", buf);
-    LogMessage("    Memcap (in bytes): %lu\n", config->memcap);
-    LogMessage("    Number of Nodes:   %ld\n", config->memcap / ps_node_size());
+    LogMessage("    Memcap (in bytes): %zu\n", config->memcap);
+    LogMessage("    Number of Nodes:   %zu\n", config->memcap / ps_node_size());
 
     if ( config->logfile )
         LogMessage("    Logfile:           %s\n", "yes");
index e06ff785f13fa616dd6e9f363c518694366de4b1..8e493f626077ac2fa34de26105e80c5ef2465100 100644 (file)
@@ -76,7 +76,7 @@ struct PS_ALERT_CONF
 
 struct PortscanConfig
 {
-    unsigned long memcap;
+    size_t memcap;
 
     int detect_scans;
     int detect_scan_type;
index 8b2a3885e6df88b26d5d2f71f681452ffbe97fc3..0a53d4fd3bd65f66bfd89e8bc7b3571dd0bd8d2f 100644 (file)
@@ -41,16 +41,16 @@ using namespace snort;
 
 static const Parameter scan_params[] =
 {
-    { "scans", Parameter::PT_INT, "0:", "100",
+    { "scans", Parameter::PT_INT, "0:65535", "100",
       "scan attempts" },
 
-    { "rejects", Parameter::PT_INT, "0:", "15",
+    { "rejects", Parameter::PT_INT, "0:65535", "15",
       "scan attempts with negative response" },
 
-    { "nets", Parameter::PT_INT, "0:", "25",
+    { "nets", Parameter::PT_INT, "0:65535", "25",
       "number of times address changed from prior attempt" },
 
-    { "ports", Parameter::PT_INT, "0:", "25",
+    { "ports", Parameter::PT_INT, "0:65535", "25",
       "number of times port (or proto) changed from prior attempt" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -58,7 +58,7 @@ static const Parameter scan_params[] =
 
 static const Parameter ps_params[] =
 {
-    { "memcap", Parameter::PT_INT, "1:", "1048576",
+    { "memcap", Parameter::PT_INT, "1:maxSZ", "1048576",
       "maximum tracker memory in bytes" },
 
     { "protos", Parameter::PT_MULTI, protos, "all",
@@ -121,16 +121,16 @@ static const Parameter ps_params[] =
     { "icmp_sweep", Parameter::PT_TABLE, scan_params, nullptr,
       "ICMP sweep scan configuration (one-to-many)" },
 
-    { "tcp_window", Parameter::PT_INT, "0:", "0",
+    { "tcp_window", Parameter::PT_INT, "0:max32", "0",
       "detection interval for all TCP scans" },
 
-    { "udp_window", Parameter::PT_INT, "0:", "0",
+    { "udp_window", Parameter::PT_INT, "0:max32", "0",
       "detection interval for all UDP scans" },
 
-    { "ip_window", Parameter::PT_INT, "0:", "0",
+    { "ip_window", Parameter::PT_INT, "0:max32", "0",
       "detection interval for all IP scans" },
 
-    { "icmp_window", Parameter::PT_INT, "0:", "0",
+    { "icmp_window", Parameter::PT_INT, "0:max32", "0",
       "detection interval for all ICMP scans" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -235,18 +235,18 @@ bool PortScanModule::begin(const char* fqn, int, SnortConfig*)
 bool PortScanModule::set(const char* fqn, Value& v, SnortConfig*)
 {
     if ( v.is("memcap") )
-        config->memcap = v.get_long();
+        config->memcap = v.get_size();
 
     else if ( v.is("protos") )
     {
-        unsigned u = v.get_long();
+        unsigned u = v.get_uint32();
         if ( u & (PS_PROTO_ALL+1) )
             u = PS_PROTO_ALL;
         config->detect_scans = u;
     }
     else if ( v.is("scan_types") )
     {
-        unsigned u = v.get_long();
+        unsigned u = v.get_uint32();
         if ( u & (PS_TYPE_ALL+1) )
             u = PS_TYPE_ALL;
         config->detect_scan_type = u;
@@ -281,42 +281,42 @@ bool PortScanModule::set(const char* fqn, Value& v, SnortConfig*)
     else if ( v.is("scans") )
     {
         if ( auto p = get_alert_conf(fqn) )
-            p->connection_count = v.get_long();
+            p->connection_count = v.get_uint16();
         else
             return false;
     }
     else if ( v.is("rejects") )
     {
         if ( auto p = get_alert_conf(fqn) )
-            p->priority_count = v.get_long();
+            p->priority_count = v.get_uint16();
         else
             return false;
     }
     else if ( v.is("nets") )
     {
         if ( auto p = get_alert_conf(fqn) )
-            p->u_ip_count = v.get_long();
+            p->u_ip_count = v.get_uint16();
         else
             return false;
     }
     else if ( v.is("ports") )
     {
         if ( auto p = get_alert_conf(fqn) )
-            p->u_port_count = v.get_long();
+            p->u_port_count = v.get_uint16();
         else
             return false;
     }
     else if ( v.is("tcp_window") )
-        config->tcp_window = v.get_long();
+        config->tcp_window = v.get_uint32();
 
     else if ( v.is("udp_window") )
-        config->udp_window = v.get_long();
+        config->udp_window = v.get_uint32();
 
     else if ( v.is("ip_window") )
-        config->ip_window = v.get_long();
+        config->ip_window = v.get_uint32();
 
     else if ( v.is("icmp_window") )
-        config->icmp_window = v.get_long();
+        config->icmp_window = v.get_uint32();
 
     else
         return false;
index ac398fc6f5f59b18363d47ee980ee763c3ef385e..29d8b39adcdb45e9ef820e8cc3cdeca86c274368 100644 (file)
@@ -115,19 +115,19 @@ bool ReputationModule::set(const char*, Value& v, SnortConfig*)
         conf->list_dir = v.get_string();
 
     else if ( v.is("memcap") )
-        conf->memcap = v.get_long();
+        conf->memcap = v.get_uint32();
 
     else if ( v.is("nested_ip") )
-        conf->nested_ip = (NestedIP)v.get_long();
+        conf->nested_ip = (NestedIP)v.get_uint8();
 
     else if ( v.is("priority") )
-        conf->priority = (IPdecision)(v.get_long() + 1);
+        conf->priority = (IPdecision)(v.get_uint8() + 1);
 
     else if ( v.is("scan_local") )
         conf->scanlocal = v.get_bool();
 
     else if ( v.is("white") )
-        conf->white_action = (WhiteAction)v.get_long();
+        conf->white_action = (WhiteAction)v.get_uint8();
 
     else if ( v.is("whitelist") )
         conf->whitelist_path = v.get_string();
index 15ca9d9f581f5cb5f8ca74dc70dd8916b5fcd5e1..ccf0c67f4cf53d5982fb2ac634e864ca1b3dfd4c 100644 (file)
@@ -94,7 +94,7 @@ static const Parameter string_list_param[] =
 
 static const Parameter instance_params[] =
 {
-    { "id", Parameter::PT_INT, "0:", nullptr, "instance ID (required)" },
+    { "id", Parameter::PT_INT, "0:max32", nullptr, "instance ID (required)" },
     { "input_spec", Parameter::PT_STRING, nullptr, nullptr, "input specification" },
     { "variables", Parameter::PT_LIST, string_list_param, nullptr, "DAQ variables" },
 
@@ -159,7 +159,7 @@ bool SFDAQModule::set(const char* fqn, Value& v, SnortConfig* sc)
     }
     else if (!strcmp(fqn, "daq.snaplen"))
     {
-        config->set_mru_size(v.get_long());
+        config->set_mru_size(v.get_uint16());
     }
     else if (!strcmp(fqn, "daq.no_promisc"))
     {
@@ -167,7 +167,7 @@ bool SFDAQModule::set(const char* fqn, Value& v, SnortConfig* sc)
     }
     else if (!strcmp(fqn, "daq.instances.id"))
     {
-        instance_id = v.get_long();
+        instance_id = v.get_uint32();
     }
     else if (!strcmp(fqn, "daq.instances.input_spec"))
     {
index 12107d4196c3f444906584c20a1be75a8ae2719d..a6b4b70321d930567713c46b544d5cd2f737474f 100644 (file)
@@ -41,7 +41,8 @@ std::vector<struct Trough::PcapReadObject> Trough::pcap_object_list;
 std::vector<std::string> Trough::pcap_queue;
 std::string Trough::pcap_filter;
 std::vector<std::string>::const_iterator Trough::pcap_queue_iter;
-long Trough::pcap_loop_count = 0;
+
+unsigned Trough::pcap_loop_count = 0;
 unsigned Trough::file_count = 0;
 
 int Trough::get_pcaps(std::vector<struct PcapReadObject> &pol)
@@ -129,7 +130,7 @@ int Trough::get_pcaps(std::vector<struct PcapReadObject> &pol)
                 {
                     struct stat sb;
                     std::string pcap_name;
-                    auto i = 0;
+                    size_t i = 0;
                     size_t pos = 0;
 
                     if (arg.empty())
index c3931f537386b33ee80042cd18c83bbc6a8c7f91..7f3c6bbe60e512031a9139cabd40369fd2168cbb 100644 (file)
@@ -35,7 +35,7 @@ public:
         SOURCE_DIR         // a directory of sources; often used with filter
     };
 
-    static void set_loop_count(long int c)
+    static void set_loop_count(unsigned c)
     {
         pcap_loop_count = c;
     }
@@ -52,7 +52,7 @@ public:
     {
         return pcap_queue.size();
     }
-    static long get_loop_count()
+    static unsigned get_loop_count()
     {
         return pcap_loop_count;
     }
@@ -70,7 +70,8 @@ private:
     static std::vector<std::string> pcap_queue;
     static std::vector<std::string>::const_iterator pcap_queue_iter;
     static std::string pcap_filter;
-    static long pcap_loop_count;
+
+    static unsigned pcap_loop_count;
     static unsigned file_count;
 };
 
index 0f27a31330e12c5905e6364db6c5d227f3208b15..2b7d6b935f38766da5af604e78a3553199c0b91b 100644 (file)
@@ -80,16 +80,6 @@ static bool set_arg(
 
     case Parameter::PT_INT:
     case Parameter::PT_PORT:
-    {
-        char* end = nullptr;
-        long n = strtol(val, &end, 0);
-
-        if ( !*end )
-            v.set(n);
-        else
-            ok = false;
-        break;
-    }
     case Parameter::PT_REAL:
     {
         char* end = nullptr;
index e035a4cf79fe428c5e0fb3ac6191edf44aeb3b0f..8f665cc6bf931c39e003ee2dd7128bb3c117ddf0 100644 (file)
@@ -69,8 +69,8 @@ from opnum established for fragmented request"
 from context id established for fragmented request"
 
 #define DCE2_MAX_XMIT_SIZE_FUZZ    500
-#define DCE2_MOCK_HDR_LEN__CO_CLI   (sizeof(DceRpcCoHdr) + sizeof(DceRpcCoRequest))
-#define DCE2_MOCK_HDR_LEN__CO_SRV   (sizeof(DceRpcCoHdr) + sizeof(DceRpcCoResponse))
+#define DCE2_MOCK_HDR_LEN__CO_CLI   ((unsigned)(sizeof(DceRpcCoHdr) + sizeof(DceRpcCoRequest)))
+#define DCE2_MOCK_HDR_LEN__CO_SRV   ((unsigned)(sizeof(DceRpcCoHdr) + sizeof(DceRpcCoResponse)))
 #define DCE2_CO__MIN_ALLOC_SIZE     50
 #define DCE2_LITTLE_ENDIAN 0x10
 
index 2798fe6ad6549f209d0a230c7a855215f3934984..bcd873c903f2ebf8cbdc30c8e50119eff7492ac8 100644 (file)
@@ -88,9 +88,11 @@ bool dce2_set_common_config(Value& v, dce2CommonProtoConf& common)
         common.disable_defrag = v.get_bool();
 
     else if ( v.is("max_frag_len") )
-        common.max_frag_len = v.get_long();
+        common.max_frag_len = v.get_uint16();
+
     else
         return false;
+
     return true;
 }
 
@@ -98,12 +100,16 @@ bool dce2_set_co_config(Value& v, dce2CoProtoConf& co)
 {
     if (dce2_set_common_config(v, co.common))
         return true;
+
     else if ( v.is("policy") )
-        co.policy = (DCE2_Policy)v.get_long();
+        co.policy = (DCE2_Policy)v.get_uint8();
+
     else if ( v.is("reassemble_threshold") )
-        co.co_reassemble_threshold = v.get_long();
+        co.co_reassemble_threshold = v.get_uint16();
+
     else
         return false;
+
     return true;
 }
 
index c8e46a16c67301b15364c74fb9e814fabfa2af7c..f71e4a1b0587356b16240ad2a449dadb98dc98f5 100644 (file)
@@ -481,9 +481,9 @@ public:
 
 // Used for reassembled packets
 #define DCE2_MOCK_HDR_LEN__SMB_CLI \
-    (sizeof(NbssHdr) + sizeof(SmbNtHdr) + sizeof(SmbWriteAndXReq))
+    ((unsigned)(sizeof(NbssHdr) + sizeof(SmbNtHdr) + sizeof(SmbWriteAndXReq)))
 #define DCE2_MOCK_HDR_LEN__SMB_SRV \
-    (sizeof(NbssHdr) + sizeof(SmbNtHdr) + sizeof(SmbReadAndXResp))
+    ((unsigned)(sizeof(NbssHdr) + sizeof(SmbNtHdr) + sizeof(SmbReadAndXResp)))
 
 DCE2_SmbSsnData* get_dce2_smb_session_data(snort::Flow*);
 
index b9a58c52faae36da3a1a604fda26d99261a80639..b727429307f17bd87c484aed1bbc63c1840f643a 100644 (file)
@@ -101,34 +101,43 @@ static const char* dce2SmbFingerprintPolicyStrings[] =
 static const Parameter s_params[] =
 {
     { "disable_defrag", Parameter::PT_BOOL, nullptr, "false",
-      " Disable DCE/RPC defragmentation" },
+      "disable DCE/RPC defragmentation" },
+
     { "max_frag_len", Parameter::PT_INT, "1514:65535", "65535",
-      " Maximum fragment size for defragmentation" },
+      "maximum fragment size for defragmentation" },
+
     { "reassemble_threshold", Parameter::PT_INT, "0:65535", "0",
-      " Minimum bytes received before performing reassembly" },
-    { "smb_fingerprint_policy", Parameter::PT_ENUM,
-      "none | client |  server | both ", "none",
-      " Target based SMB policy to use" },
+      "minimum bytes received before performing reassembly" },
+
+    { "smb_fingerprint_policy", Parameter::PT_ENUM, "none | client |  server | both ", "none",
+      "target based SMB policy to use" },
+
     { "policy", Parameter::PT_ENUM,
-      "Win2000 |  WinXP | WinVista | Win2003 | Win2008 | Win7 | Samba | Samba-3.0.37 | Samba-3.0.22 | Samba-3.0.20",
-      "WinXP",
-      " Target based policy to use" },
+      "Win2000 |  WinXP | WinVista | Win2003 | Win2008 | Win7 | Samba | Samba-3.0.37 | "
+      "Samba-3.0.22 | Samba-3.0.20", "WinXP",
+      "target based policy to use" },
+
     { "smb_max_chain", Parameter::PT_INT, "0:255", "3",
-      " SMB max chain size" },
+      "SMB max chain size" },
+
     { "smb_max_compound", Parameter::PT_INT, "0:255", "3",
-      " SMB max compound size" },
-    { "valid_smb_versions", Parameter::PT_MULTI,
-      "v1 | v2 | all", "all",
-      " Valid SMB versions" },
-    { "smb_file_inspection", Parameter::PT_ENUM,
-      "off | on | only", "off",
-      " SMB file inspection" },
-    { "smb_file_depth", Parameter::PT_INT, "-1:", "16384",
-      " SMB file depth for file data" },
+      "SMB max compound size" },
+
+    { "valid_smb_versions", Parameter::PT_MULTI, "v1 | v2 | all", "all",
+      "valid SMB versions" },
+
+    { "smb_file_inspection", Parameter::PT_ENUM, "off | on | only", "off",
+      "SMB file inspection" },
+
+    { "smb_file_depth", Parameter::PT_INT, "-1:32767", "16384",
+      "SMB file depth for file data" },
+
     { "smb_invalid_shares", Parameter::PT_STRING, nullptr, nullptr,
       "SMB shares to alert on " },
+
     { "smb_legacy_mode", Parameter::PT_BOOL, nullptr, "false",
       "inspect only SMBv1" },
+
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
@@ -431,24 +440,34 @@ bool Dce2SmbModule::set(const char* fqn, snort::Value& v, snort::SnortConfig* c)
 {
     if (dce2_set_co_config(v,config.common))
         return true;
+
     else if ( v.is("smb_fingerprint_policy") )
-        config.smb_fingerprint_policy = (dce2SmbFingerprintPolicy)v.get_long();
+        config.smb_fingerprint_policy = (dce2SmbFingerprintPolicy)v.get_uint8();
+
     else if ( v.is("smb_max_chain") )
-        config.smb_max_chain = v.get_long();
+        config.smb_max_chain = v.get_uint8();
+
     else if ( v.is("smb_max_compound") )
-        config.smb_max_compound = v.get_long();
+        config.smb_max_compound = v.get_uint8();
+
     else if ( v.is("valid_smb_versions") )
         set_smb_versions_mask(config,v.get_string());
+
     else if ( v.is("smb_file_inspection") )
-        config.smb_file_inspection = (dce2SmbFileInspection)v.get_long();
+        config.smb_file_inspection = (dce2SmbFileInspection)v.get_uint8();
+
     else if ( v.is("smb_file_depth") )
-        config.smb_file_depth = v.get_long();
+        config.smb_file_depth = v.get_int16();
+
     else if ( v.is("smb_invalid_shares") )
         return(set_smb_invalid_shares(config,v));
+
     else if ( v.is("smb_legacy_mode"))
         config.legacy_mode = v.get_bool();
+
     else
         return Module::set(fqn, v, c);
+
     return true;
 }
 
index 2afc548532ee1ba5873c7de2a04301fb03b85010..9f226da27dcb8a5f8b8e78edbb75ad49a4adebbf 100644 (file)
@@ -34,15 +34,19 @@ using namespace std;
 static const Parameter s_params[] =
 {
     { "disable_defrag", Parameter::PT_BOOL, nullptr, "false",
-      " Disable DCE/RPC defragmentation" },
+      "disable DCE/RPC defragmentation" },
+
     { "max_frag_len", Parameter::PT_INT, "1514:65535", "65535",
-      " Maximum fragment size for defragmentation" },
+      "maximum fragment size for defragmentation" },
+
     { "reassemble_threshold", Parameter::PT_INT, "0:65535", "0",
-      " Minimum bytes received before performing reassembly" },
+      "minimum bytes received before performing reassembly" },
+
     { "policy", Parameter::PT_ENUM,
       "Win2000 |  WinXP | WinVista | Win2003 | Win2008 | Win7 | "
       "Samba | Samba-3.0.37 | Samba-3.0.22 | Samba-3.0.20", "WinXP",
-      " Target based policy to use" },
+      "target based policy to use" },
+
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
index 1ce1cc42bd048ca232ea85faf02fbe7fe7dcd441..d2967bca445881513e230cd1650fbb9529124a44 100644 (file)
@@ -36,9 +36,11 @@ Trace TRACE_NAME(dce_udp);
 static const Parameter s_params[] =
 {
     { "disable_defrag", Parameter::PT_BOOL, nullptr, "false",
-      " Disable DCE/RPC defragmentation" },
+      "disable DCE/RPC defragmentation" },
+
     { "max_frag_len", Parameter::PT_INT, "1514:65535", "65535",
-      " Maximum fragment size for defragmentation" },
+      "maximum fragment size for defragmentation" },
+
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
index 521d47918c5fa15dfefd9b031e5e5ca9520ce830..f84e29140126fe595b4d69c0c390ee93719f3573 100644 (file)
@@ -156,8 +156,10 @@ static const Parameter s_params[] =
 {
     { "group", Parameter::PT_INT, "0:255", "0",
       "match given DNP3 object header group" },
+
     { "var", Parameter::PT_INT, "0:255", "0",
       "match given DNP3 object header var" },
+
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
@@ -188,9 +190,10 @@ bool Dnp3ObjModule::begin(const char*, int, SnortConfig*)
 bool Dnp3ObjModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("group") )
-        group = v.get_long();
+        group = v.get_uint8();
+
     else if ( v.is("var") )
-        var = v.get_long();
+        var = v.get_uint8();
 
     return true;
 }
index 282b10fc135c6e095ee3b5634577e1769b84e476..4bb23329aa0bacb83aa31328012f83ad9d11401a 100644 (file)
@@ -48,10 +48,10 @@ static const Parameter client_bounce_params[] =
       "allowed IP address in CIDR format" },
 
     // FIXIT-L port and last_port should be replaced with a port list
-    { "port", Parameter::PT_PORT, "1:", "20",
+    { "port", Parameter::PT_PORT, nullptr, "20",
       "allowed port" },
 
-    { "last_port", Parameter::PT_PORT, "0:", nullptr,
+    { "last_port", Parameter::PT_PORT, nullptr, nullptr,
       "optional allowed range from port to last_port inclusive" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -68,7 +68,7 @@ static const Parameter ftp_client_params[] =
     { "ignore_telnet_erase_cmds", Parameter::PT_BOOL, nullptr, "false",
       "ignore erase character and erase line commands when normalizing" },
 
-    { "max_resp_len", Parameter::PT_INT, "-1:", "-1",
+    { "max_resp_len", Parameter::PT_INT, "0:max32", "4294967295",
       "maximum FTP response accepted by client" },
 
     { "telnet_cmds", Parameter::PT_BOOL, nullptr, "false",
@@ -107,13 +107,13 @@ bool FtpClientModule::set(const char*, Value& v, SnortConfig*)
         conf->ignore_telnet_erase_cmds = v.get_bool();
 
     else if ( v.is("last_port") )
-        last_port = v.get_long();
+        last_port = v.get_uint16();
 
     else if ( v.is("max_resp_len") )
-        conf->max_resp_len = v.get_long();
+        conf->max_resp_len = v.get_uint32();
 
     else if ( v.is("port") )
-        port = v.get_long();
+        port = v.get_uint16();
 
     else if ( v.is("telnet_cmds") )
         conf->telnet_cmds = v.get_bool();
@@ -243,7 +243,7 @@ static const Parameter ftp_server_validity_params[] =
     { "format", Parameter::PT_STRING, nullptr, nullptr,
       "format specification" },
 
-    { "length", Parameter::PT_INT, "0:", "0",
+    { "length", Parameter::PT_INT, "0:max32", "0",
       "specify non-default maximum for command" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -254,7 +254,7 @@ static const Parameter ftp_directory_params[] =
     { "dir_cmd", Parameter::PT_STRING, nullptr, nullptr,
       "directory command" },
 
-    { "rsp_code", Parameter::PT_INT, "200:", "200",
+    { "rsp_code", Parameter::PT_INT, "200:max32", "200",
       "expected successful response code for command" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -295,7 +295,7 @@ static const Parameter ftp_server_params[] =
     { "cmd_validity", Parameter::PT_LIST, ftp_server_validity_params, nullptr,
       "specify command formats" },
 
-    { "def_max_param_len", Parameter::PT_INT, "1:", "100",
+    { "def_max_param_len", Parameter::PT_INT, "1:max32", "100",
       "default maximum length of commands handled by server; 0 is unlimited" },
 
     { "encrypted_traffic", Parameter::PT_BOOL, nullptr, "false",
@@ -419,7 +419,7 @@ bool FtpServerModule::set(const char*, Value& v, SnortConfig*)
         add_commands(v, CMD_XFER);
 
     else if ( v.is("def_max_param_len") )
-        conf->def_max_param_len = v.get_long();
+        conf->def_max_param_len = v.get_uint32();
 
     else if ( v.is("dir_cmd") )
         names = v.get_string();
@@ -449,7 +449,7 @@ bool FtpServerModule::set(const char*, Value& v, SnortConfig*)
         conf->ignore_telnet_erase_cmds = v.get_bool();
 
     else if ( v.is("length") )
-        number = v.get_long();
+        number = v.get_uint32();
 
     else if ( v.is("login_cmds") )
         add_commands(v, CMD_LOGIN);
@@ -458,7 +458,7 @@ bool FtpServerModule::set(const char*, Value& v, SnortConfig*)
         conf->print_commands = v.get_bool();
 
     else if ( v.is("rsp_code") )
-        number = v.get_long();
+        number = v.get_uint32();
 
     else if ( v.is("telnet_cmds") )
         conf->telnet_cmds = v.get_bool();
index 2289d94fb05cffe1583750dd5f2d44bf1c72040d..f24e51e137264f8ffbd914237fbda68eff1fd9e1 100644 (file)
@@ -44,7 +44,7 @@ using namespace std;
 
 static const Parameter s_params[] =
 {
-    { "ayt_attack_thresh", Parameter::PT_INT, "-1:", "-1",
+    { "ayt_attack_thresh", Parameter::PT_INT, "-1:max31", "-1",
       "alert on this number of consecutive Telnet AYT commands" },
 
     { "check_encrypted", Parameter::PT_BOOL, nullptr, "false",
@@ -98,7 +98,7 @@ ProfileStats* TelnetModule::get_profile() const
 bool TelnetModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("ayt_attack_thresh") )
-        conf->ayt_threshold = v.get_long();
+        conf->ayt_threshold = v.get_int32();
 
     else if ( v.is("check_encrypted") )
         conf->detect_encrypted = v.get_bool();
index 17f4eb56fb68e8bdab37cc1e7d85d2abec4b2459..037be03818de6b119393abd3fece4bd06397a5f7 100644 (file)
@@ -128,13 +128,13 @@ GtpInspectModule::GtpInspectModule() :
 bool GtpInspectModule::set(const char* fqn, Value& v, SnortConfig* c)
 {
     if ( v.is("version") )
-        stuff.version = v.get_long();
+        stuff.version = v.get_uint8();
 
     else if ( v.is("type") )
-        stuff.type = v.get_long();
+        stuff.type = v.get_uint8();
 
     else if ( v.is("length") )
-        stuff.length = v.get_long();
+        stuff.length = v.get_uint8();
 
     else if ( v.is("name") )
         stuff.name = v.get_string();
index 7968252792f5e3db48ff8335b881406a1f2bfd7a..7ed990df96f5e530747bd593d2340f4e31e24a91 100644 (file)
@@ -128,7 +128,7 @@ bool GtpVersionModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    version = v.get_long();
+    version = v.get_uint8();
     return true;
 }
 
index 220fb3715a935445b1dceaa575de779ef97aeeeb..898e462fa7c572f52768fc2f338c1efbc97e494c 100644 (file)
@@ -33,57 +33,90 @@ using namespace HttpEnums;
 
 const Parameter HttpModule::http_params[] =
 {
-    { "request_depth", Parameter::PT_INT, "-1:", "-1",
-          "maximum request message body bytes to examine (-1 no limit)" },
-    { "response_depth", Parameter::PT_INT, "-1:", "-1",
-          "maximum response message body bytes to examine (-1 no limit)" },
-    { "unzip", Parameter::PT_BOOL, nullptr, "true", "decompress gzip and deflate message bodies" },
+    { "request_depth", Parameter::PT_INT, "-1:max53", "-1",
+      "maximum request message body bytes to examine (-1 no limit)" },
+
+    { "response_depth", Parameter::PT_INT, "-1:max53", "-1",
+      "maximum response message body bytes to examine (-1 no limit)" },
+
+    { "unzip", Parameter::PT_BOOL, nullptr, "true",
+      "decompress gzip and deflate message bodies" },
+
     { "normalize_utf", Parameter::PT_BOOL, nullptr, "true",
-          "normalize charset utf encodings in response bodies" },
+      "normalize charset utf encodings in response bodies" },
+
     { "decompress_pdf", Parameter::PT_BOOL, nullptr, "false",
-          "decompress pdf files in response bodies" },
+      "decompress pdf files in response bodies" },
+
     { "decompress_swf", Parameter::PT_BOOL, nullptr, "false",
-          "decompress swf files in response bodies" },
+      "decompress swf files in response bodies" },
+
     { "normalize_javascript", Parameter::PT_BOOL, nullptr, "false",
-          "normalize javascript in response bodies" },
+      "normalize javascript in response bodies" },
+
     { "max_javascript_whitespaces", Parameter::PT_INT, "1:65535", "200",
-          "maximum consecutive whitespaces allowed within the Javascript obfuscated data" },
+      "maximum consecutive whitespaces allowed within the Javascript obfuscated data" },
+
     { "bad_characters", Parameter::PT_BIT_LIST, "255", nullptr,
-          "alert when any of specified bytes are present in URI after percent decoding" },
+      "alert when any of specified bytes are present in URI after percent decoding" },
+
     { "ignore_unreserved", Parameter::PT_STRING, "(optional)", nullptr,
-          "do not alert when the specified unreserved characters are percent-encoded in a URI."
-          "Unreserved characters are 0-9, a-z, A-Z, period, underscore, tilde, and minus." },
-    { "percent_u", Parameter::PT_BOOL, nullptr, "false", "normalize %uNNNN and %UNNNN encodings" },
+      "do not alert when the specified unreserved characters are percent-encoded in a URI."
+      "Unreserved characters are 0-9, a-z, A-Z, period, underscore, tilde, and minus." },
+
+    { "percent_u", Parameter::PT_BOOL, nullptr, "false",
+      "normalize %uNNNN and %UNNNN encodings" },
+
     { "utf8", Parameter::PT_BOOL, nullptr, "true",
-          "normalize 2-byte and 3-byte UTF-8 characters to a single byte" },
+      "normalize 2-byte and 3-byte UTF-8 characters to a single byte" },
+
     { "utf8_bare_byte", Parameter::PT_BOOL, nullptr, "false",
-          "when doing UTF-8 character normalization include bytes that were not percent encoded" },
+      "when doing UTF-8 character normalization include bytes that were not percent encoded" },
+
     { "iis_unicode", Parameter::PT_BOOL, nullptr, "false",
-          "use IIS unicode code point mapping to normalize characters" },
+      "use IIS unicode code point mapping to normalize characters" },
+
     { "iis_unicode_map_file", Parameter::PT_STRING, "(optional)", nullptr,
-          "file containing code points for IIS unicode." },
+      "file containing code points for IIS unicode." },
+
     { "iis_unicode_code_page", Parameter::PT_INT, "0:65535", "1252",
-          "code page to use from the IIS unicode map file" },
+      "code page to use from the IIS unicode map file" },
+
     { "iis_double_decode", Parameter::PT_BOOL, nullptr, "false",
-          "perform double decoding of percent encodings to normalize characters" },
+      "perform double decoding of percent encodings to normalize characters" },
+
     { "oversize_dir_length", Parameter::PT_INT, "1:65535", "300",
-          "maximum length for URL directory" },
+      "maximum length for URL directory" },
+
     { "backslash_to_slash", Parameter::PT_BOOL, nullptr, "false",
-          "replace \\ with / when normalizing URIs" },
+      "replace \\ with / when normalizing URIs" },
+
     { "plus_to_space", Parameter::PT_BOOL, nullptr, "true",
-          "replace + with <sp> when normalizing URIs" },
+      "replace + with <sp> when normalizing URIs" },
+
     { "simplify_path", Parameter::PT_BOOL, nullptr, "true",
-          "reduce URI directory path to simplest form" },
+      "reduce URI directory path to simplest form" },
+
 #ifdef REG_TEST
-    { "test_input", Parameter::PT_BOOL, nullptr, "false", "read HTTP messages from text file" },
-    { "test_output", Parameter::PT_BOOL, nullptr, "false", "print out HTTP section data" },
-    { "print_amount", Parameter::PT_INT, "1:1000000", "1200",
-          "number of characters to print from a Field" },
+    { "test_input", Parameter::PT_BOOL, nullptr, "false",
+      "read HTTP messages from text file" },
+
+    { "test_output", Parameter::PT_BOOL, nullptr, "false",
+      "print out HTTP section data" },
+
+    { "print_amount", Parameter::PT_INT, "1:max53", "1200",
+      "number of characters to print from a Field" },
+
     { "print_hex", Parameter::PT_BOOL, nullptr, "false",
       "nonprinting characters printed in [HH] format instead of using an asterisk" },
-    { "show_pegs", Parameter::PT_BOOL, nullptr, "true", "display peg counts with test output" },
-    { "show_scan", Parameter::PT_BOOL, nullptr, "false", "display scanned segments" },
+
+    { "show_pegs", Parameter::PT_BOOL, nullptr, "true",
+      "display peg counts with test output" },
+
+    { "show_scan", Parameter::PT_BOOL, nullptr, "false",
+      "display scanned segments" },
 #endif
+
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
@@ -105,11 +138,11 @@ bool HttpModule::set(const char*, Value& val, SnortConfig*)
 {
     if (val.is("request_depth"))
     {
-        params->request_depth = val.get_long();
+        params->request_depth = val.get_int64();
     }
     else if (val.is("response_depth"))
     {
-        params->response_depth = val.get_long();
+        params->response_depth = val.get_int64();
     }
     else if (val.is("unzip"))
     {
@@ -133,7 +166,7 @@ bool HttpModule::set(const char*, Value& val, SnortConfig*)
     }
     else if (val.is("max_javascript_whitespaces"))
     {
-        params->js_norm_param.max_javascript_whitespaces = val.get_long();
+        params->js_norm_param.max_javascript_whitespaces = val.get_uint16();
     }
     else if (val.is("bad_characters"))
     {
@@ -169,7 +202,7 @@ bool HttpModule::set(const char*, Value& val, SnortConfig*)
     }
     else if (val.is("iis_unicode_code_page"))
     {
-        params->uri_param.iis_unicode_code_page = val.get_long();
+        params->uri_param.iis_unicode_code_page = val.get_uint16();
     }
     else if (val.is("iis_double_decode"))
     {
@@ -177,7 +210,7 @@ bool HttpModule::set(const char*, Value& val, SnortConfig*)
     }
     else if (val.is("oversize_dir_length"))
     {
-        params->uri_param.oversize_dir_length = val.get_long();
+        params->uri_param.oversize_dir_length = val.get_uint16();
     }
     else if (val.is("backslash_to_slash"))
     {
@@ -206,7 +239,7 @@ bool HttpModule::set(const char*, Value& val, SnortConfig*)
     }
     else if (val.is("print_amount"))
     {
-        params->print_amount = val.get_long();
+        params->print_amount = val.get_int64();
     }
     else if (val.is("print_hex"))
     {
@@ -264,6 +297,8 @@ HttpParaList::UriParam::UriParam() :
   // 0-9, a-z, A-Z, tilde, period, underscore, and minus
   // Initializer string for std::bitset is in reverse order. The first character is element 255
   // and the last is element 0.
+
+// __STRDUMP_DISABLE__
   unreserved_char { std::string(
       "00000000" "00000000" "00000000" "00000000"
       "00000000" "00000000" "00000000" "00000000"
@@ -273,6 +308,7 @@ HttpParaList::UriParam::UriParam() :
       "10000111" "11111111" "11111111" "11111110"
       "00000011" "11111111" "01100000" "00000000"
       "00000000" "00000000" "00000000" "00000000" ) },
+// __STRDUMP_ENABLE__
 
   uri_char {
     CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,    CHAR_NORMAL,
index d66118d44668f79000fe7d02b531b09c5f4928fb..ee92ede2b71dc332ca5ecf8e09edad0807620988 100644 (file)
@@ -34,8 +34,9 @@
 struct HttpParaList
 {
 public:
-    long request_depth;
-    long response_depth;
+    int64_t request_depth;
+    int64_t response_depth;
+
     bool unzip;
     bool normalize_utf = true;
     bool decompress_pdf = false;
@@ -76,9 +77,10 @@ public:
     UriParam uri_param;
 
 #ifdef REG_TEST
+    int64_t print_amount;
+
     bool test_input;
     bool test_output;
-    long print_amount;
     bool print_hex;
     bool show_pegs;
     bool show_scan;
index 82577eb178e972c3c04016a4e834e6a557a28a2b..04c9d504aacb13c5a86b5a60459b97901d336ee5 100644 (file)
@@ -88,16 +88,21 @@ ProfileStats* ImapModule::get_profile() const
 
 bool ImapModule::set(const char*, Value& v, SnortConfig*)
 {
-    const long value = v.get_long();
-    const long mime_value = (value > 0) ? value : -(value+1); // flip 0 and -1 for MIME processing
+    const int32_t value = v.get_int32();
+    const int32_t mime_value = (value > 0) ? value : -(value+1); // flip 0 and -1 for MIME use
+
     if ( v.is("b64_decode_depth") )
         config->decode_conf.set_b64_depth(mime_value);
+
     else if ( v.is("bitenc_decode_depth") )
         config->decode_conf.set_bitenc_depth(mime_value);
+
     else if ( v.is("qp_decode_depth") )
         config->decode_conf.set_qp_depth(mime_value);
+
     else if ( v.is("uu_decode_depth") )
         config->decode_conf.set_uu_depth(mime_value);
+
     else
         return false;
 
index b9c419c5b8e1ff36fa4bb476203607f2a8fb3643..91b820ae909b5bfd97284e2960d9444ef083490b 100644 (file)
@@ -131,7 +131,7 @@ bool ModbusUnitModule::set(const char*, Value& v, SnortConfig*)
     if ( !v.is("~") )
         return false;
 
-    unit = v.get_long();
+    unit = v.get_uint8();
     return true;
 }
 
index a7f894b6bc0796f2b4982307b25e5d97e382272f..313f934beb945bee23d9c3c31d2d428be2f63a74 100644 (file)
@@ -87,16 +87,21 @@ ProfileStats* PopModule::get_profile() const
 
 bool PopModule::set(const char*, Value& v, SnortConfig*)
 {
-    const long value = v.get_long();
-    const long mime_value = (value > 0) ? value : -(value+1); // flip 0 and -1 for MIME processing
+    const int32_t value = v.get_int32();
+    const int32_t mime_value = (value > 0) ? value : -(value+1); // flip 0 and -1 for MIME use
+
     if ( v.is("b64_decode_depth") )
         config->decode_conf.set_b64_depth(mime_value);
+
     else if ( v.is("bitenc_decode_depth") )
         config->decode_conf.set_bitenc_depth(mime_value);
+
     else if ( v.is("qp_decode_depth") )
         config->decode_conf.set_qp_depth(mime_value);
+
     else if ( v.is("uu_decode_depth") )
         config->decode_conf.set_uu_depth(mime_value);
+
     else
         return false;
 
index 4823b286762f7191883d4ae1be72ff41349d3913..c6e4144d8023c5388f077765314cef7645ee1fb8 100644 (file)
@@ -128,7 +128,7 @@ IpsOption::EvalStatus SipStatCodeOption::eval(Cursor&, Packet* p)
 static const Parameter s_params[] =
 {
     { "*code", Parameter::PT_INT, "1:999", nullptr,
-      "stat code" },
+      "status code" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
@@ -166,15 +166,14 @@ bool SipStatCodeModule::set(const char*, Value& v, SnortConfig*)
     {
         if ( v.is("*code") )
         {
-            unsigned long statCode = v.get_long();
+            uint16_t statCode = v.get_uint16();
 
-            if ((statCode > MAX_STAT_CODE) || ((statCode > NUM_OF_RESPONSE_TYPES - 1) &&
-                (statCode < MIN_STAT_CODE)))
+            if ( (statCode >= NUM_OF_RESPONSE_TYPES) && (statCode < MIN_STAT_CODE) )
             {
-                ParseError("Status code specified is not a 3 digit number or 1");
+                ParseError("Status code specified is not a single digit or a 3 digit number");
                 return false;
             }
-            ssod.stat_codes[num_tokens] = (uint16_t)statCode;
+            ssod.stat_codes[num_tokens] = statCode;
             num_tokens++;
         }
         else
index 3925a07cca0b7c788ad4e38ffdad8d082e5000a3..60f395bb120b8d361409dc75890ea463c8507517 100644 (file)
@@ -72,7 +72,7 @@ static const Parameter s_params[] =
     { "max_content_len", Parameter::PT_INT, "0:65535", "1024",
       "maximum content length of the message body" },
 
-    { "max_dialogs", Parameter::PT_INT, "1:4194303", "4",
+    { "max_dialogs", Parameter::PT_INT, "1:max32", "4",
       "maximum number of dialogs within one stream session" },
 
     { "max_from_len", Parameter::PT_INT, "0:65535", "256",
@@ -201,31 +201,31 @@ bool SipModule::set(const char*, Value& v, SnortConfig*)
         conf->ignoreChannel = v.get_bool();
 
     else if ( v.is("max_call_id_len") )
-        conf->maxCallIdLen = v.get_long();
+        conf->maxCallIdLen = v.get_uint16();
 
     else if ( v.is("max_contact_len") )
-        conf->maxContactLen = v.get_long();
+        conf->maxContactLen = v.get_uint16();
 
     else if ( v.is("max_content_len") )
-        conf->maxContentLen = v.get_long();
+        conf->maxContentLen = v.get_uint16();
 
     else if ( v.is("max_dialogs") )
-        conf->maxNumDialogsInSession = v.get_long();
+        conf->maxNumDialogsInSession = v.get_uint32();
 
     else if ( v.is("max_from_len") )
-        conf->maxFromLen = v.get_long();
+        conf->maxFromLen = v.get_uint16();
 
     else if ( v.is("max_requestName_len") )
-        conf->maxRequestNameLen = v.get_long();
+        conf->maxRequestNameLen = v.get_uint16();
 
     else if ( v.is("max_to_len") )
-        conf->maxToLen = v.get_long();
+        conf->maxToLen = v.get_uint16();
 
     else if ( v.is("max_uri_len") )
-        conf->maxUriLen = v.get_long();
+        conf->maxUriLen = v.get_uint16();
 
     else if ( v.is("max_via_len") )
-        conf->maxViaLen = v.get_long();
+        conf->maxViaLen = v.get_uint16();
 
     else if ( v.is("methods") )
         sip_methods = v.get_string();
index 13639c5974db2b49155e068949b8c56adab1042a..a46a5d7010f626da89ff1304a129b005f3fb2e8c 100644 (file)
@@ -56,7 +56,7 @@ static const Parameter smtp_command_params[] =
     { "command", Parameter::PT_STRING, nullptr, nullptr,
       "command string" },
 
-    { "length", Parameter::PT_INT, "0:", "0",
+    { "length", Parameter::PT_INT, "0:max32", "0",
       "specify non-default maximum for command" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -226,15 +226,15 @@ bool SmtpModule::set(const char*, Value& v, SnortConfig*)
 
     else if ( v.is("b64_decode_depth") )
     {
-        const long value = v.get_long();
-        const long mime_value = (value > 0) ? value : -(value+1);
+        const int32_t value = v.get_int32();
+        const int32_t mime_value = (value > 0) ? value : -(value+1);
         config->decode_conf.set_b64_depth(mime_value);
     }
 
     else if ( v.is("bitenc_decode_depth") )
     {
-        const long value = v.get_long();
-        const long mime_value = (value > 0) ? value : -(value+1);
+        const int32_t value = v.get_int32();
+        const int32_t mime_value = (value > 0) ? value : -(value+1);
         config->decode_conf.set_bitenc_depth(mime_value);
     }
 
@@ -248,7 +248,7 @@ bool SmtpModule::set(const char*, Value& v, SnortConfig*)
         add_commands(v, PCMD_DATA);
 
     else if ( v.is("email_hdrs_log_depth") )
-        config->log_config.email_hdrs_log_depth = v.get_long();
+        config->log_config.email_hdrs_log_depth = v.get_uint16();
 
     else if ( v.is("ignore_data") )
         config->decode_conf.set_ignore_data(v.get_bool());
@@ -260,7 +260,7 @@ bool SmtpModule::set(const char*, Value& v, SnortConfig*)
         add_commands(v, PCMD_INVALID);
 
     else if ( v.is("length") )
-        number = v.get_long();
+        number = v.get_uint32();
 
     else if ( v.is("log_filename") )
         config->log_config.log_filename =v.get_bool();
@@ -275,27 +275,27 @@ bool SmtpModule::set(const char*, Value& v, SnortConfig*)
         config->log_config.log_email_hdrs = v.get_bool();
 
     else if ( v.is("max_auth_command_line_len") )
-        config->max_auth_command_line_len = v.get_long();
+        config->max_auth_command_line_len = v.get_uint16();
 
     else if ( v.is("max_command_line_len") )
-        config->max_command_line_len = v.get_long();
+        config->max_command_line_len = v.get_uint16();
 
     else if ( v.is("max_header_line_len") )
-        config->max_header_line_len = v.get_long();
+        config->max_header_line_len = v.get_uint16();
 
     else if ( v.is("max_response_line_len") )
-        config->max_response_line_len = v.get_long();
+        config->max_response_line_len = v.get_uint16();
 
     else if ( v.is("normalize") )
-        config->normalize = (NORM_TYPES)v.get_long();
+        config->normalize = (NORM_TYPES)v.get_uint8();
 
     else if ( v.is("normalize_cmds"))
         add_commands(v, PCMD_NORM);
 
     else if ( v.is("qp_decode_depth") )
     {
-        const long value = v.get_long();
-        const long mime_value = (value > 0) ? value : -(value+1);
+        const int32_t value = v.get_int32();
+        const int32_t mime_value = (value > 0) ? value : -(value+1);
         config->decode_conf.set_qp_depth(mime_value);
     }
 
@@ -304,13 +304,13 @@ bool SmtpModule::set(const char*, Value& v, SnortConfig*)
 
     else if ( v.is("uu_decode_depth") )
     {
-        const long value = v.get_long();
-        const long mime_value = (value > 0) ? value : -(value+1);
+        const int32_t value = v.get_int32();
+        const int32_t mime_value = (value > 0) ? value : -(value+1);
         config->decode_conf.set_uu_depth(mime_value);
     }
 
     else if ( v.is("xlink2state") )
-        config->xlink2state = (XLINK2STATE)v.get_long();
+        config->xlink2state = (XLINK2STATE)v.get_uint8();
 
     else
         return false;
index 9389d9ae32233abab3993a624a242b30d65553da..55caf0cb90c542dd4c9615f5dba2b8809513c91e 100644 (file)
@@ -106,13 +106,13 @@ ProfileStats* SshModule::get_profile() const
 bool SshModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("max_encrypted_packets") )
-        conf->MaxEncryptedPackets = v.get_long();
+        conf->MaxEncryptedPackets = v.get_uint16();
 
     else if ( v.is("max_client_bytes") )
-        conf->MaxClientBytes = v.get_long();
+        conf->MaxClientBytes = v.get_uint16();
 
     else if ( v.is("max_server_version_len") )
-        conf->MaxServerVersionLen = v.get_long();
+        conf->MaxServerVersionLen = v.get_uint8();
 
     else
         return false;
index b949e56fe6ddbed8cba61030e7ee4129d0856119..c219da7dec23dfe454a1234e3bd705a4687a21b2 100644 (file)
@@ -88,7 +88,7 @@ bool SslModule::set(const char*, Value& v, SnortConfig*)
         conf->trustservers = v.get_bool();
 
     else if ( v.is("max_heartbeat_length") )
-        conf->max_heartbeat_len = v.get_long();
+        conf->max_heartbeat_len = v.get_uint16();
 
     else
         return false;
index a405bd5ceb42826b6696519fcc20c37a8db7a962..ac40fa24338e6b53c94c9ae380d37acfed68c667 100644 (file)
@@ -41,6 +41,7 @@ typedef struct
 
 static IP_entry ip_lists[] =
 {
+// __STRDUMP_DISABLE__
     { "192.168.0.1",4 },
     { "2.16.0.1", 100 },
     { "12.16.0.1", 500 },
@@ -55,6 +56,7 @@ static IP_entry ip_lists[] =
     { "ffee:ddcc:bbaa:9988:7766:5544:3322:1100/32", 121 },
     { "1001:db8:85a3::/29", 122 },
     { "255.255.255.255", 0 }
+// __STRDUMP_ENABLE__
 };
 
 //---------------------------------------------------------------
index 1d9ef6390933619b774b99ea654855a2c2ca1ce7..b08dd7dd7ce644dd1fe241f2ab21818a4eb71e46 100644 (file)
@@ -38,13 +38,13 @@ Trace TRACE_NAME(stream);
 #define CACHE_PARAMS(name, max, prune, idle, cleanup) \
 static const Parameter name[] = \
 { \
-    { "max_sessions", Parameter::PT_INT, "2:", max, \
+    { "max_sessions", Parameter::PT_INT, "2:max32", max, \
       "maximum simultaneous sessions tracked before pruning" }, \
  \
-    { "pruning_timeout", Parameter::PT_INT, "1:", prune, \
+    { "pruning_timeout", Parameter::PT_INT, "1:max32", prune, \
       "minimum inactive time before being eligible for pruning" }, \
  \
-    { "idle_timeout", Parameter::PT_INT, "1:", idle, \
+    { "idle_timeout", Parameter::PT_INT, "1:max32", idle, \
       "maximum inactive time before retiring session tracker" }, \
  \
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr } \
@@ -63,7 +63,7 @@ CACHE_PARAMS(file_params,    "128",  "30",  "180", "5");
 
 static const Parameter s_params[] =
 {
-    { "footprint", Parameter::PT_INT, "0:", "0",
+    { "footprint", Parameter::PT_INT, "0:max32", "0",
       "use zero for production, non-zero for testing at given size (for TCP and user)" },
 
     { "ip_frags_only", Parameter::PT_BOOL, nullptr, "false",
@@ -127,7 +127,7 @@ bool StreamModule::set(const char* fqn, Value& v, SnortConfig* c)
 
     if ( v.is("footprint") )
     {
-        config.footprint = v.get_long();
+        config.footprint = v.get_uint32();
         return true;
     }
     else if ( v.is("ip_frags_only") )
@@ -157,13 +157,13 @@ bool StreamModule::set(const char* fqn, Value& v, SnortConfig* c)
         return Module::set(fqn, v, c);
 
     if ( v.is("max_sessions") )
-        fc->max_sessions = v.get_long();
+        fc->max_sessions = v.get_uint32();
 
     else if ( v.is("pruning_timeout") )
-        fc->pruning_timeout = v.get_long();
+        fc->pruning_timeout = v.get_uint32();
 
     else if ( v.is("idle_timeout") )
-        fc->nominal_timeout = v.get_long();
+        fc->nominal_timeout = v.get_uint32();
 
     else
         return false;
index d180eb9f9f3f04b2eeaa1d9af70d49ab20b63e31..65828f1cae7506dc0c5fff0af31715ad9df9d68d 100644 (file)
@@ -72,7 +72,7 @@ struct StreamModuleConfig
     FlowConfig user_cfg;
     FlowConfig file_cfg;
 
-    int footprint;
+    unsigned footprint;
     bool ip_frags_only;
     bool track_on_syn;
 };
index abd5bc391a3e2e71b4246d2ed06af43d869829f1..e32938d5270e8de4d3e144bbfe709773f2c56653 100644 (file)
@@ -35,7 +35,7 @@ using namespace std;
 
 static const Parameter s_params[] =
 {
-    { "session_timeout", Parameter::PT_INT, "1:86400", "30",
+    { "session_timeout", Parameter::PT_INT, "1:max31", "30",
       "session tracking timeout" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -62,7 +62,7 @@ StreamIcmpConfig* StreamIcmpModule::get_data()
 bool StreamIcmpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("session_timeout") )
-        config->session_timeout = v.get_long();
+        config->session_timeout = v.get_uint32();
 
     else
         return false;
index 02ea8fd38c78908d30d34b303b722ddb5b2f8ca7..8f6faeec1a158cbb94114bbe9c3e6ba97c306f1e 100644 (file)
@@ -102,13 +102,13 @@ static const RuleMap stream_ip_rules[] =
 
 static const Parameter s_params[] =
 {
-    { "max_frags", Parameter::PT_INT, "1:", "8192",
+    { "max_frags", Parameter::PT_INT, "1:max32", "8192",
       "maximum number of simultaneous fragments being tracked" },
 
-    { "max_overlaps", Parameter::PT_INT, "0:", "0",
+    { "max_overlaps", Parameter::PT_INT, "0:max32", "0",
       "maximum allowed overlaps per datagram; 0 is unlimited" },
 
-    { "min_frag_length", Parameter::PT_INT, "0:", "0",
+    { "min_frag_length", Parameter::PT_INT, "0:65535", "0",
       "alert if fragment length is below this limit before or after trimming" },
 
     { "min_ttl", Parameter::PT_INT, "1:255", "1",
@@ -117,7 +117,7 @@ static const Parameter s_params[] =
     { "policy", Parameter::PT_ENUM, IP_POLICIES, "linux",
       "fragment reassembly policy" },
 
-    { "session_timeout", Parameter::PT_INT, "1:86400", "30",
+    { "session_timeout", Parameter::PT_INT, "1:max31", "30",
       "session tracking timeout" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -174,25 +174,25 @@ StreamIpConfig* StreamIpModule::get_data()
 bool StreamIpModule::set(const char* f, Value& v, SnortConfig* c)
 {
     if ( v.is("max_frags") )
-        config->frag_engine.max_frags = v.get_long();
+        config->frag_engine.max_frags = v.get_uint32();
 
     else if ( v.is("max_overlaps") )
-        config->frag_engine.max_overlaps = v.get_long();
+        config->frag_engine.max_overlaps = v.get_uint32();
 
     else if ( v.is("min_frag_length") )
-        config->frag_engine.min_fragment_length = v.get_long();
+        config->frag_engine.min_fragment_length = v.get_uint32();
 
     else if ( v.is("min_ttl") )
-        config->frag_engine.min_ttl = v.get_long();
+        config->frag_engine.min_ttl = v.get_uint8();
 
     else if ( v.is("policy") )
-        config->frag_engine.frag_policy = v.get_long() + 1;
+        config->frag_engine.frag_policy = v.get_uint16() + 1;
 
     else if ( v.is("session_timeout") )
     {
         // FIXIT-L need to integrate to eliminate redundant data
-        config->session_timeout = v.get_long();
-        config->frag_engine.frag_timeout = v.get_long();
+        config->session_timeout = v.get_uint32();
+        config->frag_engine.frag_timeout = v.get_uint32();
     }
     else
         return Module::set(f, v, c);
index 8993bf5b42d8fcb8bc3acc9b90a3f9e2dd3ca25b..21b9a565ec11459c61be9391637a4a2e7fcb5e53 100644 (file)
@@ -216,10 +216,10 @@ bool ReassembleModule::begin(const char*, int, SnortConfig*)
 bool ReassembleModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("action") )
-        srod.enable = v.get_long();
+        srod.enable = v.get_uint8();
 
     else if ( v.is("direction") )
-        srod.direction = v.get_long() + 1;
+        srod.direction = v.get_uint8() + 1;
 
     else if ( v.is("noalert") )
         srod.alert = 0;
index 1def6ebade19b938b535e8f9173d429d86ba56e9..953b511e9bae7bd188e0a70a0edea27eb6a9710c 100644 (file)
@@ -206,7 +206,7 @@ bool SizeModule::set(const char*, Value& v, SnortConfig*)
         return ssod.validate(v.get_string(), RANGE);
 
     else if ( v.is("~direction") )
-        direction = v.get_long();
+        direction = v.get_uint8();
 
     else
         return false;
index 3b3b44e18b9d3cc9a639542c9c5f5ad2734dd5ea..39dd982cb18006f2f678b2ad28d057aaaae0e10a 100644 (file)
@@ -143,10 +143,10 @@ static const Parameter stream_tcp_small_params[] =
 
 static const Parameter stream_queue_limit_params[] =
 {
-    { "max_bytes", Parameter::PT_INT, "0:", "1048576",
+    { "max_bytes", Parameter::PT_INT, "0:max32", "1048576",
       "don't queue more than given bytes per session and direction" },
 
-    { "max_segments", Parameter::PT_INT, "0:", "2621",
+    { "max_segments", Parameter::PT_INT, "0:max32", "2621",
       "don't queue more than given segments per session and direction" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -154,13 +154,13 @@ static const Parameter stream_queue_limit_params[] =
 
 static const Parameter s_params[] =
 {
-    { "flush_factor", Parameter::PT_INT, "0:", "0",
+    { "flush_factor", Parameter::PT_INT, "0:65535", "0",
       "flush upon seeing a drop in segment size after given number of non-decreasing segments" },
 
     { "max_window", Parameter::PT_INT, "0:1073725440", "0",
       "maximum allowed TCP window" },
 
-    { "overlap_limit", Parameter::PT_INT, "0:255", "0",
+    { "overlap_limit", Parameter::PT_INT, "0:max32", "0",
       "maximum number of allowed overlapping segments per session" },
 
     { "max_pdu", Parameter::PT_INT, "1460:32768", "16384",
@@ -172,7 +172,7 @@ static const Parameter s_params[] =
     { "reassemble_async", Parameter::PT_BOOL, nullptr, "true",
       "queue data for reassembly before traffic is seen in both directions" },
 
-    { "require_3whs", Parameter::PT_INT, "-1:86400", "-1",
+    { "require_3whs", Parameter::PT_INT, "-1:max31", "-1",
       "don't track midstream sessions after given seconds from start up; -1 tracks all" },
 
     { "show_rebuilt_packets", Parameter::PT_BOOL, nullptr, "false",
@@ -184,7 +184,7 @@ static const Parameter s_params[] =
     { "small_segments", Parameter::PT_TABLE, stream_tcp_small_params, nullptr,
       "limit number of small segments queued" },
 
-    { "session_timeout", Parameter::PT_INT, "1:86400", "30",
+    { "session_timeout", Parameter::PT_INT, "1:max31", "30",
       "session tracking timeout" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -284,34 +284,34 @@ TcpStreamConfig* StreamTcpModule::get_data()
 bool StreamTcpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("count") )
-        config->max_consec_small_segs = v.get_long();
+        config->max_consec_small_segs = v.get_uint16();
 
     else if ( v.is("maximum_size") )
-        config->max_consec_small_seg_size = v.get_long();
+        config->max_consec_small_seg_size = v.get_uint16();
 
     else if ( v.is("flush_factor") )
-        config->flush_factor = v.get_long();
+        config->flush_factor = v.get_uint16();
 
     else if ( v.is("max_bytes") )
-        config->max_queued_bytes = v.get_long();
+        config->max_queued_bytes = v.get_uint32();
 
     else if ( v.is("max_segments") )
-        config->max_queued_segs = v.get_long();
+        config->max_queued_segs = v.get_uint32();
 
     else if ( v.is("max_window") )
-        config->max_window = v.get_long();
+        config->max_window = v.get_uint32();
 
     else if ( v.is("max_pdu") )
-        config->paf_max = v.get_long();
+        config->paf_max = v.get_uint16();
 
     else if ( v.is("policy") )
-        config->policy = static_cast< StreamPolicy >( v.get_long() + 1 );
+        config->policy = static_cast< StreamPolicy >( v.get_uint8() + 1 );
 
     else if ( v.is("overlap_limit") )
-        config->overlap_limit = v.get_long();
+        config->overlap_limit = v.get_uint32();
 
     else if ( v.is("session_timeout") )
-        config->session_timeout = v.get_long();
+        config->session_timeout = v.get_uint32();
 
     else if ( v.is("reassemble_async") )
     {
@@ -322,7 +322,7 @@ bool StreamTcpModule::set(const char*, Value& v, SnortConfig*)
     }
     else if ( v.is("require_3whs") )
     {
-        config->hs_timeout = v.get_long();
+        config->hs_timeout = v.get_int32();
     }
     else if ( v.is("show_rebuilt_packets") )
     {
index 687ed6aae319841f1fe705cc123c0cc42dd085b2..162609c0f8b8ef3e564c8d536380d3f9384b59ab 100644 (file)
@@ -35,7 +35,7 @@ using namespace std;
 
 static const Parameter s_params[] =
 {
-    { "session_timeout", Parameter::PT_INT, "1:86400", "30",
+    { "session_timeout", Parameter::PT_INT, "1:max31", "30",
       "session tracking timeout" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -62,7 +62,7 @@ StreamUdpConfig* StreamUdpModule::get_data()
 bool StreamUdpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("session_timeout") )
-        config->session_timeout = v.get_long();
+        config->session_timeout = v.get_uint32();
 
     else
         return false;
index 5d939dfe7226327b1a927a8f2f47f01e101bc934..72a22a6d2955ef5ac84869baffd4b7e0d04efb9d 100644 (file)
@@ -36,7 +36,7 @@ Trace TRACE_NAME(stream_user);
 
 static const Parameter s_params[] =
 {
-    { "session_timeout", Parameter::PT_INT, "1:86400", "30",
+    { "session_timeout", Parameter::PT_INT, "1:max31", "30",
       "session tracking timeout" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -64,7 +64,7 @@ StreamUserConfig* StreamUserModule::get_data()
 bool StreamUserModule::set(const char* fqn, Value& v, SnortConfig* sc)
 {
     if ( v.is("session_timeout") )
-        config->session_timeout = v.get_long();
+        config->session_timeout = v.get_uint32();
 
     else
         return Module::set(fqn, v, sc);
index 34d2b64ca246becd94cfe4bddf53d4722fc2a11b..e1c734a32cff149aed4ab7a0e2345c8a409d631f 100644 (file)
@@ -169,7 +169,7 @@ void ts_print(const struct timeval* tvp, char* timebuf)
     if (SnortConfig::output_use_utc())
         localzone = 0;
 
-    int s = (tvp->tv_sec + localzone) % 86400;
+    int s = (tvp->tv_sec + localzone) % SECONDS_PER_DAY;
     time_t Time = (tvp->tv_sec + localzone) - s;
 
     struct tm ttm;
index 3c1e3e90885a4e0e052feea740277771dc839b3b..73120792da027739657ec57b5ba09a1ca7e79a72 100644 (file)
@@ -283,5 +283,18 @@ static const ConvertMap tagged_packet_limit_api =
 };
 
 const ConvertMap* tagged_packet_limit_map = &tagged_packet_limit_api;
+
+/**************************************************
+ ********************* umask  *********************
+ **************************************************/
+
+static const std::string umask = "umask";
+static const ConvertMap umask_api =
+{
+    umask,
+    config_int_ctor<& umask, & process>,
+};
+
+const ConvertMap* umask_map = &umask_api;
 } // namespace config
 
index 846af24a7219fa4c2dcfbec37bc6d053fb19b5ab..d91100cfc210da068cbea945d0a95aaa83d15d92 100644 (file)
@@ -257,18 +257,5 @@ static const ConvertMap set_uid_api =
 };
 
 const ConvertMap* set_uid_map = &set_uid_api;
-
-/**************************************************
- ********************* umask  *********************
- **************************************************/
-
-static const std::string umask = "umask";
-static const ConvertMap umask_api =
-{
-    umask,
-    config_string_ctor<& umask, & process>,
-};
-
-const ConvertMap* umask_map = &umask_api;
 } // namespace config
 
index 8a1b7af75c501f747ecf6549a79bb781daaee273..98a176c05e41b57fc2dc7658a8d2cab47ae58b2c 100644 (file)
@@ -121,7 +121,7 @@ static bool get_record(u2iterator* it, u2record* record)
     if (bytes_read != sizeof(uint32_t)*2)
     {
         puts("ERROR: Failed to read record metadata.");
-        printf("\tRead %u of %lu bytes\n", bytes_read, (unsigned long)sizeof(uint32_t)*2);
+        printf("\tRead %u of %zu bytes\n", bytes_read, sizeof(uint32_t)*2);
         return false;
     }