-- pulled thread pinning from Josh
-- snort.lua tweaks to back out random test foo
-- additional valgrind tweaks
+-- fixed several Xcode static analysis warnings
121
-- valgrind fixes
cur += used;
}
-#if 0
if (unused > 0)
{
- used = snprintf(cur, unused, "\nProcessed size: %u\n",
+ snprintf(cur, unused, "\nProcessed size: %u\n",
(unsigned int)context->processed_bytes);
- //unused -= used;
- //cur += used;
}
-#endif
buf[sizeof(buf) - 1] = '\0';
printf("%s", buf);
}
/*
- If sfthd_node list is empty - add as head node
- */
- if( !sfthd_item->sfthd_node_list->count )
- {
-#ifdef THD_DEBUG
- printf("Threshold node added to head of list\n");fflush(stdout);
-#endif
- sflist_add_head(sfthd_item->sfthd_node_list,sfthd_node);
- }
-
- /*
- else add the sfthd_node using priority to determine where in the list
+ add the sfthd_node using priority to determine where in the list
it belongs
3.0 we can have only 1 threshold object but several suppression objects
list, the tail node is either a supprssion node or the only pure
thresholding node.
*/
- else
{
SF_LNODE* lnode;
NODE_DATA ndata;
}
}
+ /*
+ sfthd_node list is empty - add as head node
+ */
+ assert( !sfthd_item->sfthd_node_list->count );
+ {
+#ifdef THD_DEBUG
+ printf("Threshold node added to head of list\n");fflush(stdout);
+#endif
+ sflist_add_head(sfthd_item->sfthd_node_list,sfthd_node);
+ }
+
return 0;
}
}
else
{
- if ( flow->was_blocked() )
+ if ( flow && flow->was_blocked() )
blocks++;
if ( !hash_table->touch() )
{
Module* mod = ModuleManager::get_module(p.api.base.name);
handler = p.api.ctor(mod);
- handler->set_api(&p.api);
- handler->add_ref();
+
+ if ( handler )
+ {
+ handler->set_api(&p.api);
+ handler->add_ref();
+ }
}
PHInstance::~PHInstance()
{
- handler->rem_ref();
+ if ( handler )
+ handler->rem_ref();
}
typedef vector<PHGlobal*> PHGlobalList;
// get special options first
while ( al.get_arg(key, val) )
- set(key, val, sc, false);
+ ::set(key, val, sc, false);
// now get the rest
al.reset();
while ( al.get_arg(key, val) )
- set(key, val, sc, true);
+ ::set(key, val, sc, true);
check_flags(sc);
*/
static void * bnfa_alloc( int n, int * m )
{
+ if ( !n )
+ return nullptr;
void * p = calloc(1,n);
if( p ) {
if(m) {
/* sanity check we have not overflowed our buffer */
if( ps_index > nps ) {
/* Fatal */
+ BNFA_FREE(pi,bnfa->bnfaNumStates*sizeof(bnfa_state_t),bnfa->nextstate_memory);
return -1;
}
/* check for buffer overflow again */
if( ps_index > nps ) {
/* Fatal */
+ BNFA_FREE(pi,bnfa->bnfaNumStates*sizeof(bnfa_state_t),bnfa->nextstate_memory);
return -1;
}
int (*Match)(void * id, void *tree, int index, void *data, void *neg_list),
void *data, unsigned sindex, int* current_state )
{
+ assert(current_state);
int ret = 0;
if (current_state) {
OptFmt = (FTP_DATE_FMT *)calloc(1, sizeof(FTP_DATE_FMT));
if (OptFmt == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
CurrFmt->format_string = curr_format;
- curr_len = 0;
}
*format = curr_ch;
return FTPP_SUCCESS;
NewFmt = (FTP_DATE_FMT *)calloc(1, sizeof(FTP_DATE_FMT));
if (NewFmt == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
if (curr_len > 0)
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
NewFmt = (FTP_DATE_FMT *)calloc(1, sizeof(FTP_DATE_FMT));
if (NewFmt == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
NewFmt->prev = LastNonOptFmt;
NewFmt = (FTP_DATE_FMT *)calloc(1, sizeof(FTP_DATE_FMT));
if (NewFmt == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
NewFmt->prev = CurrFmt;
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
CurrFmt->format_string = curr_format;
- curr_len = 0;
*format = curr_ch;
return FTPP_SUCCESS;
}
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
CurrFmt->format_string = curr_format;
- curr_len = 0;
*format = curr_ch;
return FTPP_SUCCESS;
}
curr_format = (char *)calloc(curr_len + 1, sizeof(char));
if (curr_format == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strncpy(curr_format, start_ch, curr_len);
CurrFmt->format_string = curr_format;
- start_ch = curr_ch;
- curr_len = 0;
}
/* Should've closed all options & ORs */
HeadFmt = (FTP_PARAM_FMT *)calloc(1, sizeof(FTP_PARAM_FMT));
if (HeadFmt == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
HeadFmt->type = e_head;
FTPCmd = (FTP_CMD_CONF *)calloc(1, sizeof(FTP_CMD_CONF)+strlen(cmd));
if (FTPCmd == NULL)
{
- ParseError("Failed to allocate memory");
+ FatalError("Failed to allocate memory");
}
strcpy(FTPCmd->cmd_name, cmd);
if (iRet == FTPP_SUCCESS)
{
this_param = NextFmt->next_param+1;
- valid = 1;
break;
}
}
alt_dsize = sizeof(HttpDecodeBuf.data);
}
/* not checking if sd== NULL as the body_ptr.uri = NULL when sd === NULL in hi_server_inspect_body */
- if(sd->decomp_state && sd->decomp_state->decompress_data)
+ if(sd && sd->decomp_state && sd->decomp_state->decompress_data)
{
status = SafeMemcpy(HttpDecodeBuf.data, Server->response.body,
alt_dsize, HttpDecodeBuf.data, HttpDecodeBuf.data + sizeof(HttpDecodeBuf.data));
}
else
{
- if(sd->resp_state.last_pkt_chunked)
+ if(sd && sd->resp_state.last_pkt_chunked)
{
SetHttpDecode((uint16_t)alt_dsize);
Server->response.body = HttpDecodeBuf.data;
sfip_var_t *swp;
sfip_var_t *p;
int ret;
- SFIP_RET status;
+ SFIP_RET status = SFIP_FAILURE;
if(!table || !str || !ipret) return SFIP_FAILURE;
var = sfvar_alloc(table, str, &status);
if( var == NULL )
{
- return status;
+ return SFIP_FAILURE;
}
/* If this is an alias of another var, id will be set */
DEBUG_WRAP(PrintHostAttributeEntry(host););
ipAddr = &host->ipAddr;
+ assert(ipAddr);
ret = sfrt_insert(ipAddr, (unsigned char)ipAddr->bits, host,
RT_FAVOR_SPECIFIC, next_cfg->lookupTable);
ptr++;
}
- dst = s.output.data;
+ //dst = s.output.data; FIXIT-L dead store; should be?
*bytes_copied = s.output.len;
return iRet;
(*ptr)++;
}
- dst = s.dest.data;
+ //dst = s.dest.data; FIXIT-L dead store; should be?
*bytes_copied = s.dest.len;
return RET_OK;