codec.next_prot_id = ProtocolId::ETHERTYPE_IPV4;
break;
-#if defined(AF_INET6)
case AF_INET6: /* IPv6 */
codec.next_prot_id = ProtocolId::ETHERTYPE_IPV6;
break;
-#endif
default:
/* FIXIT-L add decoder drop event for unknown pflog network type
ssize_t recv (int, void *buf, size_t n, int)
{
if ( (s_rec_error_size == -1) ||
- ( (s_rec_error_size != -1) && (s_rec_error_size == (int)n) ) )
+ (s_rec_error_size == (int)n) )
{
if ( s_rec_return_zero )
return 0;
FileVerdict FileEnforcer::check_verdict(Flow* flow, FileNode* node, SFXHASH_NODE* hash_node)
{
- FileVerdict verdict = FILE_VERDICT_UNKNOWN;
-
// Query the file policy in case verdict has been changed
// Check file type first
FilePolicy& inspect = FileService::get_inspect();
assert(node->file);
- verdict = inspect.type_lookup(flow, node->file);
+ FileVerdict verdict = inspect.type_lookup(flow, node->file);
if ((verdict == FILE_VERDICT_UNKNOWN) ||
(verdict == FILE_VERDICT_STOP_CAPTURE))
{
tSFRFTrackingNode* dynNode = NULL;
tSFRFTrackingNodeKey key;
- SFXHASH_NODE* hnode = NULL;
/* Setup key */
key.ip = *(ip);
/*
* Check for any Permanent sid objects for this gid or add this one ...
*/
- hnode = sfxhash_get_node(rf_hash, (void*)&key);
+ SFXHASH_NODE* hnode = sfxhash_get_node(rf_hash, (void*)&key);
if ( hnode && hnode->data )
{
dynNode = (tSFRFTrackingNode*)hnode->data;
THD_NODE* sfthd_node;
unsigned gen_id;
SFGHASH_NODE* item_hash_node;
- PolicyId policyId;
for (gen_id=0; gen_id < THD_MAX_GENID; gen_id++ )
{
{
DebugFormat(DEBUG_STREAM_STATE,
"Stream: Ignoring packet from %s. Marking flow marked as ignore.\n",
- p->packet_flags & PKT_FROM_CLIENT ? "sender" : "responder");
+ (p->packet_flags & PKT_FROM_CLIENT) ? "sender" : "responder");
flow->ssn_state.ignore_direction = ignore;
DisableInspection();
{
int i;
SFGHASH* t;
- SFGHASH_NODE* n, * m;
+ SFGHASH_NODE* n;
char str[256],* p;
int num=100;
SFXHASH_NODE* sfxhash_get_node(SFXHASH* t, const void* key)
{
int index = 0;
- SFXHASH_NODE* hnode = nullptr;
/* Enforce uniqueness: Check for the key in the table */
- hnode = sfxhash_find_node_row(t, key, &index);
+ SFXHASH_NODE* hnode = sfxhash_find_node_row(t, key, &index);
if ( hnode )
{
t->cnode = hnode;
// the capacity of the LruCache.
TEST(lru_cache_shared, lru_removal_test)
{
- std::string data;
LruCacheShared<int, std::string, std::hash<int> > lru_cache(5);
for (int i = 0; i < 10; i++)
host_cache.insert((const uint8_t*) ht->get_ip_addr().get_ip6_ptr(), sptr);
}
-// FIXIT-L ipaddr should probably be a reference
-bool host_cache_add_service(SfIp ipaddr, Protocol ipproto, Port port, const char* /*service*/)
+bool host_cache_add_service(const SfIp& ipaddr, Protocol ipproto, Port port, const char* /*service*/)
{
HostIpKey ipkey((const uint8_t*) ipaddr.get_ip6_ptr());
uint16_t proto = 0; // FIXIT-M not safe with multithreads snort_conf->proto_ref->add(service));
void host_cache_add_host_tracker(HostTracker*);
// Insert a new service into host cache if it doesn't already exist.
-SO_PUBLIC bool host_cache_add_service(SfIp, Protocol, Port, const char* service);
+SO_PUBLIC bool host_cache_add_service(const SfIp&, Protocol, Port, const char* service);
#endif
}
}
-#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
if ((SnortConfig::get_pcre_match_limit_recursion() != -1) &&
!(pcre_data->options & SNORT_OVERRIDE_MATCH_LIMIT))
{
SnortConfig::get_pcre_match_limit_recursion();
}
}
-#endif
}
else
{
pcre_data->pe->match_limit = SnortConfig::get_pcre_match_limit();
}
-#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
if (SnortConfig::get_pcre_match_limit_recursion() != -1)
{
pcre_data->pe->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
pcre_data->pe->match_limit_recursion =
SnortConfig::get_pcre_match_limit_recursion();
}
-#endif
}
}
static void replace_parse(const char* args, string& s)
{
bool negated;
- std::string buf;
if ( !parse_byte_code(args, negated, s) )
return;
const char* fmt_range_message(unsigned min, unsigned max);
inline void set_script_dir(
- lua_State* L, const std::string varname, const std::string path)
+ lua_State* L, const std::string& varname, const std::string& path)
{
std::string dir = path.substr(0, path.rfind(LUA_DIR_SEP));
lua_pushlstring(L, dir.c_str(), dir.size());
// process (wire-only) packet verdicts here
static DAQ_Verdict update_verdict(DAQ_Verdict verdict, int& inject)
{
+ // FIXIT-M X PKT_RESIZED is a superset of PKT_MODIFIED, so this conditional is broken
if ( Active::packet_was_dropped() and Active::can_block() )
{
if ( verdict == DAQ_VERDICT_PASS )
s_connector_commons.clear();
}
-Connector* ConnectorManager::get_connector(const std::string connector_name)
+Connector* ConnectorManager::get_connector(const std::string& connector_name)
{
DebugFormat(DEBUG_SIDE_CHANNEL, "ConnectorManager::get_connector(): name: %s\n",
connector_name.c_str());
static void thread_term();
/* get_connector() returns the thread-specific object. */
- static Connector* get_connector(const std::string name);
+ static Connector* get_connector(const std::string& name);
};
#endif
// override prior outputs
// (last cmdline option wins)
s_loggers.outputs.clear();
- string tmp = name;
const char* pfx = (sc->output_flags & OUTPUT_FLAG__ALERTS) ? "alert_" : "log_";
Output* p = get_out(name, pfx);
cat << EOF
ffi = require("ffi")
ffi.cdef[[
-$(grep -v -e '^ *//' -e '^ *#' -e '^ *extern "C"' $1)
+$(sed -e '/^ *\/\//d' -e '/^ *#/d' -e '/^ *extern "C"/d' $1)
]]
EOF
}
#ifdef PIGLET
-PlugType PluginManager::get_type_from_name(std::string name)
+PlugType PluginManager::get_type_from_name(const std::string& name)
{
for ( auto it = plug_map.begin(); it != plug_map.end(); ++it )
{
static const BaseApi* get_api(PlugType, const char* name);
#ifdef PIGLET
- static PlugType get_type_from_name(std::string);
+ static PlugType get_type_from_name(const std::string&);
#endif
static const char* get_current_plugin();
key = line;
*value = '\0';
value++;
- for (; *value && *value == ' '; value++)
- ;
+ while (*value == ' ')
+ value++;
if (strcasecmp(key, "ports") == 0)
{
for (ptr = strtok_r(value, ",", &context); ptr; ptr = strtok_r(nullptr, ",",
&context))
{
- for (; *ptr && *ptr == ' '; ptr++)
- ;
+ while (*ptr == ' ')
+ ptr++;
len = strlen(ptr);
for (; len && ptr[len - 1] == ' '; len--)
ptr[len - 1] = 0;
asd->common.flags = flow_flags;
asd->common.policyId = appIdPolicyId;
- asd->common.policyId = appIdPolicyId;
if (asd->get_session_flags(APPID_SESSION_IGNORE_FLOW))
{
static const RNAClientAppModule* GetNextFromClientPatternList(ClientAppMatch** match_list)
{
- ClientAppMatch* curr = nullptr;
ClientAppMatch* prev = nullptr;
ClientAppMatch* max_curr = nullptr;
ClientAppMatch* max_prev = nullptr;
unsigned max_count;
unsigned max_precedence;
- curr = *match_list;
+ ClientAppMatch* curr = *match_list;
max_count = 0;
max_precedence = 0;
while (curr)
tmp = strchr(begin, *(adata+i));
if (tmp)
{
- if ((!end) || (end && tmp < end))
+ if (!end || tmp < end)
end = tmp;
}
}
}
if ((tmp = strchr(begin, 0x0a)))
{
- if ((!end) || (end && tmp < end))
+ if (!end || tmp < end)
end = tmp;
}
}
{
buffPtr = (uint8_t*)strstr((char*)start, (char*)APPLE_EMAIL_PATTERNS[i]);
appleEmailDetect = ((uint8_t*)buffPtr &&
- (i != 0 || (i == 0 && buffPtr == ((uint8_t*)start))));
+ (i != 0 || buffPtr == ((uint8_t*)start)));
}
if (appleEmailDetect)
{
if ( referer_len > 0 )
{
- data = nullptr;
patterns[0].pattern = (uint8_t*)referer_start;
patterns[0].patternSize = referer_len;
patterns[1].pattern = (uint8_t*)referer_path;
#ifdef UNIT_TESTING
if (app_id_debug_session_flag && currState != fd->state)
{
- DEBUG_WRAP(DebugMessage(DEBUG_APPID, "AppIdDbg %s SMTP client state %s\n", app_id_debug_session, stateName[fd->state]););
+ DEBUG_WRAP(DebugFormat(DEBUG_APPID, "AppIdDbg %s SMTP client state %s\n", app_id_debug_session, stateName[fd->state]););
currState = fd->state;
}
#endif
static inline int get_chp_pattern_data_and_size(lua_State* L, int index, char** pattern_data,
size_t* pattern_size)
{
- const char* tmpString = nullptr; // Lua owns this pointer
+ const char* tmpString; // Lua owns this pointer
*pattern_size = 0;
*pattern_data = nullptr;
- tmpString = lua_tolstring(L, index, &*pattern_size);
+ tmpString = lua_tolstring(L, index, pattern_size);
// non-empty pattern required
if (!tmpString || !*pattern_size)
{
static inline int get_chp_action_data(lua_State* L, int index, char** action_data)
{
// An empty string is translated into a nullptr pointer because the action data is optional
- const char* tmpString = nullptr; // Lua owns this pointer
+ const char* tmpString; // Lua owns this pointer
size_t action_data_size = 0;
tmpString = lua_tolstring(L, index, &action_data_size);
if (action_data_size)
ErrorMessage("Invalid host pattern string.");
return 0;
}
- u_int8_t* hostPattern = (u_int8_t*)snort_strdup(tmpString);
+ uint8_t* hostPattern = (uint8_t*)snort_strdup(tmpString);
/* Verify that path pattern is a valid string */
size_t pathPatternSize = 0;
snort_free(hostPattern);
return 0;
}
- u_int8_t* pathPattern = (u_int8_t*)snort_strdup(tmpString);
+ uint8_t* pathPattern = (uint8_t*)snort_strdup(tmpString);
/* Verify that scheme pattern is a valid string */
size_t schemePatternSize;
snort_free(hostPattern);
return 0;
}
- u_int8_t* schemePattern = (u_int8_t*)snort_strdup(tmpString);
+ uint8_t* schemePattern = (uint8_t*)snort_strdup(tmpString);
/* Verify that query pattern is a valid string */
size_t queryPatternSize;
if (tmpString && queryPatternSize)
queryPattern = (uint8_t*)snort_strdup(tmpString);
- u_int32_t appId = lua_tointeger(L, index++);
+ uint32_t appId = lua_tointeger(L, index++);
/* Allocate memory for data structures */
DetectorAppUrlPattern* pattern =
if ( detector->packageInfo.server.initFunctionName.empty() )
{
- RNAClientAppModule* cam = nullptr;
detector->client.appFpId = APP_ID_UNKNOWN;
- cam = &detector->client.appModule;
+ RNAClientAppModule* cam = &detector->client.appModule;
cam->name = detector->packageInfo.name.c_str();
cam->proto = detector->packageInfo.proto;
cam->validate = validate_client_application;
LogMessage("\tDetector %s: Lua Memory usage %zu kb\n", detector->name.c_str(), mem);
}
- LogMessage("Lua Stats total detectors: %lu\n", allocated_detectors.size());
+ LogMessage("Lua Stats total detectors: %zu\n", allocated_detectors.size());
LogMessage("Lua Stats total memory usage %zu kb\n", totalMem);
}
static int rshell_validate(ServiceValidationArgs* args)
{
- ServiceRSHELLData* rd = nullptr;
ServiceRSHELLData* tmp_rd = nullptr;
int i = 0;
uint32_t port = 0;
const int dir = args->dir;
uint16_t size = args->size;
- rd = (ServiceRSHELLData*)rshell_service_mod.api->data_get(asd,
+ ServiceRSHELLData* rd = (ServiceRSHELLData*)rshell_service_mod.api->data_get(asd,
rshell_service_mod.flow_data_index);
if (!rd)
{
return decision;
}
-static bool ReputationDecisionPerLayer(ReputationConfig* config, Packet* p, ip::IpApi ip_api, IPdecision* decision_final)
+static bool ReputationDecisionPerLayer(ReputationConfig* config, Packet* p,
+ const ip::IpApi& ip_api, IPdecision* decision_final)
{
const SfIp* ip;
IPdecision decision;
return NULL;
pcap = pcap_queue_iter->c_str();
- pcap_queue_iter++;
+ ++pcap_queue_iter;
/* If we've reached the end, reset the iterator if we have more
loops to cover. */
if (pcap_queue_iter == pcap_queue.cend() && pcap_loop_count > 1)
static char* mSplitAddTok(const char*, const int, const char*, const char);
-#ifdef TEST_MSTRING
-
-int main()
-{
- char test[] = "\0\0\0\0\0\0\0\0\0CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0";
- char find[] = "CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0";
-
-/* char test[] = "\x90\x90\x90\x90\x90\x90\xe8\xc0\xff\xff\xff/bin/sh\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90";
- char find[] = "\xe8\xc0\xff\xff\xff/bin/sh"; */
- int i;
- int toks;
- int* shift;
- int* skip;
-
-/* shift=make_shift(find,sizeof(find)-1);
- skip=make_skip(find,sizeof(find)-1); */
-
- DebugFormat(DEBUG_PATTERN_MATCH,"%d\n",
- mSearch(test, sizeof(test) - 1, find,
- sizeof(find) - 1, shift, skip));
-
- return 0;
-}
-
-#endif
-
/****************************************************************
*
* Function: mSplit()
* been set so the PortToFunc call can determine which port testing
* function to attach to the list
*/
- PortToFunc(rtn, (rtn->flags & ANY_DST_PORT ? 1 : 0),
- (rtn->flags & EXCEPT_DST_PORT ? 1 : 0), DST);
+ PortToFunc(rtn, (rtn->flags & ANY_DST_PORT) ? 1 : 0,
+ (rtn->flags & EXCEPT_DST_PORT) ? 1 : 0, DST);
/* as above */
- PortToFunc(rtn, (rtn->flags & ANY_SRC_PORT ? 1 : 0),
- (rtn->flags & EXCEPT_SRC_PORT ? 1 : 0), SRC);
+ PortToFunc(rtn, (rtn->flags & ANY_SRC_PORT) ? 1 : 0,
+ (rtn->flags & EXCEPT_SRC_PORT) ? 1 : 0, SRC);
/* link in the proper IP address detection function */
AddrToFunc(rtn, SRC);
class SO_PUBLIC BasePlugin
{
public:
- BasePlugin(Lua::State& lua, std::string t,
+ BasePlugin(Lua::State& lua, const std::string& t,
Module* m = nullptr, SnortConfig* sc = nullptr) :
L { lua.get_ptr() }, target { t },
module { m }, snort_conf { sc } { }
std::string target;
std::string buffer;
- Chunk(std::string f, std::string t, std::string b) :
+ Chunk(const std::string& f, const std::string& t, const std::string& b) :
filename { f }, target { t }, buffer { b } { }
};
class SoRulePiglet : public Piglet::BasePlugin
{
public:
- SoRulePiglet(Lua::State&, std::string, Module*, SnortConfig*);
+ SoRulePiglet(Lua::State&, const std::string&, Module*, SnortConfig*);
virtual ~SoRulePiglet() override;
virtual bool setup() override;
};
SoRulePiglet::SoRulePiglet(
- Lua::State& state, std::string target, Module* m, SnortConfig* sc) :
+ Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
BasePlugin(state, target, m, sc) { }
SoRulePiglet::~SoRulePiglet() { }
class TestPiglet : public Piglet::BasePlugin
{
public:
- TestPiglet(Lua::State& state, std::string target) :
+ TestPiglet(Lua::State& state, const std::string& target) :
BasePlugin(state, target) { }
virtual bool setup() override;
*/
PortObject* PortObjectDup(PortObject* po)
{
- PortObject* ponew = NULL;
PortObjectItem* poi = NULL;
PortObjectItem* poinew = NULL;
SF_LNODE* lpos = NULL;
int* prid = NULL;
int* prule = NULL;
- ponew = PortObjectNew();
+ PortObject* ponew = PortObjectNew();
if ( !ponew )
return nullptr;
*/
PortObject* PortObjectDupPorts(PortObject* po)
{
- PortObject* ponew = NULL;
PortObjectItem* poi = NULL;
PortObjectItem* poinew = NULL;
SF_LNODE* lpos = NULL;
- ponew = PortObjectNew();
+ PortObject* ponew = PortObjectNew();
if ( !ponew )
return nullptr;
int* currNode = NULL;
unsigned uniqElements = 0;
int* node = 0;
- int* rlist = NULL;
+ int* rlist;
rlist = RuleListToSortedArray(rl);
if (!rlist )
{ stats.update_deallocs(n); }
constexpr MemoryTracker() : stats() { }
- constexpr MemoryTracker(CombinedMemoryStats stats) : stats(stats) { }
+ constexpr MemoryTracker(const CombinedMemoryStats &stats) : stats(stats) { }
};
#endif
ProfileStats& operator+=(const ProfileStats&);
constexpr ProfileStats() : time(), memory() { }
- constexpr ProfileStats(TimeProfilerStats time, MemoryTracker memory) :
+ constexpr ProfileStats(const TimeProfilerStats& time, const MemoryTracker& memory) :
time(time), memory(memory) { }
};
ProfilerPrinter(const StatsTable::Field* fields, const PrintFn print, const Sorter& sort) :
fields(fields), print(print), sort(sort) { }
- void print_table(std::string title, Entry& root, unsigned count, int max_depth = -1)
+ void print_table(const std::string& title, Entry& root, unsigned count, int max_depth = -1)
{
std::ostringstream ss;
SSL_BAD_VER_FLAG | SSL_BAD_TYPE_FLAG | \
SSL_TRAILING_GARB_FLAG | SSL_UNKNOWN_FLAG))
-#define SSL_HEARTBLEED_REQUEST 0x01
+#define SSL_HEARTBLEED_REQUEST 0x01
#define SSL_HEARTBLEED_RESPONSE 0x02
-#define SSL_HEARTBLEED_UNKNOWN 0x03
+#define SSL_HEARTBLEED_UNKNOWN 0x04
SO_PUBLIC uint32_t SSL_decode(
const uint8_t* pkt, int size, uint32_t pktflags, uint32_t prevflags,
tnew->key = input;
tnew->next_state = next_state;
- tnew->next = 0;
-
tnew->next = acsm->acsmTransTable[state];
+
acsm->acsmTransTable[state] = tnew;
acsm->acsmNumTrans++;
static int Conv_Full_DFA_To_Sparse(ACSM_STRUCT2* acsm)
{
int cnt, m, k, i;
- acstate_t* p, state, maxstates=0;
+ acstate_t* p, state;
acstate_t** NextState = acsm->acsmNextState;
acstate_t full[MAX_ALPHABET_SIZE];
cnt++;
}
- if ( cnt > 0 )
- maxstates++;
-
if ( k== 0 || cnt > acsm->acsmSparseMaxRowNodes )
{
p = (acstate_t*)AC_MALLOC_DFA(sizeof(acstate_t)*(acsm->acsmAlphabetSize+2),
*/
static int _bnfa_opt_nfa(bnfa_struct_t* bnfa)
{
+#if 0
int cnt=0;
+#endif
int k, fs, fr;
bnfa_state_t* FailState = bnfa->bnfaFailState;
}
if ( fr != fs )
{
+#if 0
cnt++;
+#endif
FailState[ k ] = fs;
}
}
{
if (sc == nullptr)
return false;
- return sc->smb_fingerprint_policy
- & DCE2_SMB_FINGERPRINT_POLICY_CLIENT ? true : false;
+ return (sc->smb_fingerprint_policy
+ & DCE2_SMB_FINGERPRINT_POLICY_CLIENT) ? true : false;
}
inline bool DCE2_GcSmbFingerprintServer(const dce2SmbProtoConf* sc)
{
if (sc == nullptr)
return false;
- return sc->smb_fingerprint_policy
- & DCE2_SMB_FINGERPRINT_POLICY_SERVER ? true : false;
+ return (sc->smb_fingerprint_policy
+ & DCE2_SMB_FINGERPRINT_POLICY_SERVER) ? true : false;
}
inline bool DCE2_GcIsLegacyMode(const dce2SmbProtoConf* sc)
static DCE2_TcpSsnData* dce2_create_new_tcp_session(Packet* p, dce2TcpProtoConf* config)
{
- DCE2_TcpSsnData* dce2_tcp_sess = nullptr;
Profile profile(dce2_tcp_pstat_new_session);
DebugMessage(DEBUG_DCE_TCP, "DCE over TCP packet detected\n");
DebugMessage(DEBUG_DCE_TCP, "Creating new session\n");
- dce2_tcp_sess = set_new_dce2_tcp_session(p);
+ DCE2_TcpSsnData* dce2_tcp_sess = set_new_dce2_tcp_session(p);
if ( dce2_tcp_sess )
{
static DCE2_UdpSsnData* dce2_create_new_udp_session(Packet* p, dce2UdpProtoConf* config)
{
- DCE2_UdpSsnData* dce2_udp_sess = nullptr;
Profile profile(dce2_udp_pstat_new_session);
DebugMessage(DEBUG_DCE_UDP, "DCE over UDP packet detected\n");
DebugMessage(DEBUG_DCE_UDP, "Creating new session\n");
- dce2_udp_sess = set_new_dce2_udp_session(p);
+ DCE2_UdpSsnData* dce2_udp_sess = set_new_dce2_udp_session(p);
DCE2_ResetRopts(&dce2_udp_sess->sd.ropts);
class Dce2IfaceOption : public IpsOption
{
public:
- Dce2IfaceOption(RangeCheck iface_version, bool iface_any_frag, Uuid iface_uuid) :
+ Dce2IfaceOption(const RangeCheck& iface_version, bool iface_any_frag, const Uuid& iface_uuid) :
IpsOption(s_name), version(iface_version), any_frag(iface_any_frag), uuid(iface_uuid)
{
memset(&pmd, 0, sizeof(pmd));
static DCE2_SmbSsnData* dce2_create_new_smb_session(Packet* p, dce2SmbProtoConf* config)
{
- DCE2_SmbSsnData* dce2_smb_sess = nullptr;
Profile profile(dce2_smb_pstat_new_session);
DebugMessage(DEBUG_DCE_SMB, "DCE over SMB packet detected\n");
DebugMessage(DEBUG_DCE_SMB, "Creating new session\n");
- dce2_smb_sess = set_new_dce2_smb_session(p);
+ DCE2_SmbSsnData* dce2_smb_sess = set_new_dce2_smb_session(p);
if ( dce2_smb_sess )
{
dce2_smb_sess->dialect_index = DCE2_SENTINEL;
inline bool SmbTransactionReqDisconnectTid(const SmbTransactionReq* req)
{
- return alignedNtohs(&req->smb_flags) & 0x0001 ? true : false;
+ return (alignedNtohs(&req->smb_flags) & 0x0001) ? true : false;
}
inline bool SmbTransactionReqOneWay(const SmbTransactionReq* req)
{
- return alignedNtohs(&req->smb_flags) & 0x0002 ? true : false;
+ return (alignedNtohs(&req->smb_flags) & 0x0002) ? true : false;
}
inline uint8_t SmbTransactionReqSetupCnt(const SmbTransactionReq* req)
/* Calculate the actual length of data to inspect */
user_data = link->len - DNP3_HEADER_REMAINDER_LEN;
- num_crcs = 1 + (user_data/DNP3_CHUNK_SIZE) + (user_data % DNP3_CHUNK_SIZE ? 1 : 0);
+ num_crcs = 1 + (user_data/DNP3_CHUNK_SIZE) + ((user_data % DNP3_CHUNK_SIZE) ? 1 : 0);
pdu_length = DNP3_MIN_LEN + link->len + (DNP3_CRC_SIZE*num_crcs);
if (bytes_processed + pdu_length > p->dsize)
}
user_data = pafdata->dnp3_length - DNP3_HEADER_REMAINDER_LEN;
- num_crcs = 1 + (user_data/DNP3_CHUNK_SIZE) + (user_data % DNP3_CHUNK_SIZE ? 1 : 0);
+ num_crcs = 1 + (user_data/DNP3_CHUNK_SIZE) + ((user_data % DNP3_CHUNK_SIZE) ? 1 : 0);
pafdata->real_length = pafdata->dnp3_length + (DNP3_CRC_SIZE*num_crcs);
pafdata->paf_state = (dnp3_paf_state)(((int)pafdata->paf_state) + 1);
/* Decode group */
group = *buf;
buf++;
- buflen--;
/* Decode var */
var = *buf;
*/
static void snort_imap(IMAP_PROTO_CONF* config, Packet* p)
{
- IMAPData* imap_ssn = NULL;
- int pkt_dir;
-
/* Attempt to get a previously allocated IMAP block. */
- imap_ssn = get_session_data(p->flow);
+ IMAPData* imap_ssn = get_session_data(p->flow);
if (imap_ssn == NULL)
{
}
}
- pkt_dir = IMAP_Setup(p, imap_ssn);
+ int pkt_dir = IMAP_Setup(p, imap_ssn);
if (pkt_dir == IMAP_PKT_FROM_CLIENT)
{
*/
static void snort_pop(POP_PROTO_CONF* config, Packet* p)
{
- POPData* pop_ssn = NULL;
- int pkt_dir;
-
/* Attempt to get a previously allocated POP block. */
- pop_ssn = get_session_data(p->flow);
+ POPData* pop_ssn = get_session_data(p->flow);
if (pop_ssn == NULL)
{
}
}
- pkt_dir = POP_Setup(p, pop_ssn);
+ int pkt_dir = POP_Setup(p, pop_ssn);
if (pkt_dir == POP_PKT_FROM_CLIENT)
{
SIPMethodNode* SIP_FindMethod(SIPMethodlist methods, char* methodName, unsigned int length)
{
- SIPMethodNode* method = NULL;
-
- method = methods;
+ SIPMethodNode* method = methods;
while (NULL != method)
{
if ((length == strlen(method->methodName))&&
delete duplex_connector;
}
-Connector* ConnectorManager::get_connector(const std::string connector_name)
+Connector* ConnectorManager::get_connector(const std::string& connector_name)
{
if ( connector_name == "R" )
return receive_connector;
#include "main/snort_debug.h"
#include "utils/util.h"
-#ifdef TEST_MSTRING
-int main()
-{
- char test[] = "\0\0\0\0\0\0\0\0\0CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0";
- char find[] = "CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0";
-
-/* char test[] = "\x90\x90\x90\x90\x90\x90\xe8\xc0\xff\xff\xff/bin/sh\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90";
- char find[] = "\xe8\xc0\xff\xff\xff/bin/sh"; */
- int i;
- int toks;
- int* shift;
- int* skip;
-
-/* shift=make_shift(find,sizeof(find)-1);
- skip=make_skip(find,sizeof(find)-1); */
-
- DebugFormat(DEBUG_PATTERN_MATCH,"%d\n",
- mSearch(test, sizeof(test) - 1, find,
- sizeof(find) - 1, shift, skip));
-
- return 0;
-}
-
-#endif
-
/****************************************************************
*
* Function: make_skip(char *, int)
*/
char* sfmemcap_SnortStrdup(MEMCAP* mc, const char* str)
{
- char* data = NULL;
- int data_size;
-
- data_size = strlen(str) + 1;
- data = (char*)sfmemcap_alloc(mc, data_size);
+ int data_size = strlen(str) + 1;
+ char* data = (char*)sfmemcap_alloc(mc, data_size);
if (data == NULL)
{