Fixup code to compile with -Wall -Werror -Wextra -Wno-unused-parameter compiler options.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 4e1dc0bd83
commit b7bac14040

@ -323,14 +323,14 @@ ConfGetBool(char *name, int *val)
{
char *strval;
char *trues[] = {"1", "yes", "true", "on"};
int i;
size_t u;
*val = 0;
if (ConfGet(name, &strval) != 1)
return 0;
for (i = 0; i < sizeof(trues) / sizeof(trues[0]); i++) {
if (strcasecmp(strval, trues[i]) == 0) {
for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) {
if (strcasecmp(strval, trues[u]) == 0) {
*val = 1;
break;
}
@ -452,11 +452,11 @@ ConfDump(void)
{
HashTableBucket *b;
ConfNode *cn;
int i;
uint32_t u;
for (i = 0; i < conf_hash->array_size; i++) {
if (conf_hash->array[i] != NULL) {
b = (HashTableBucket *)conf_hash->array[i];
for (u = 0; u < conf_hash->array_size; u++) {
if (conf_hash->array[u] != NULL) {
b = (HashTableBucket *)conf_hash->array[u];
while (b != NULL) {
cn = (ConfNode *)b->data;
if (cn->val != NULL)
@ -700,10 +700,10 @@ ConfTestGetBool(void)
"no", "NO",
};
int val;
int i;
size_t u;
for (i = 0; i < sizeof(trues) / sizeof(trues[0]); i++) {
if (ConfSet(name, trues[i], 1) != 1)
for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) {
if (ConfSet(name, trues[u], 1) != 1)
return 0;
if (ConfGetBool(name, &val) != 1)
return 0;
@ -711,8 +711,8 @@ ConfTestGetBool(void)
return 0;
}
for (i = 0; i < sizeof(falses) / sizeof(falses[0]); i++) {
if (ConfSet(name, falses[i], 1) != 1)
for (u = 0; u < sizeof(falses) / sizeof(falses[0]); u++) {
if (ConfSet(name, falses[u], 1) != 1)
return 0;
if (ConfGetBool(name, &val) != 1)
return 0;
@ -727,15 +727,15 @@ static int
ConfNodeLookupChildTest(void)
{
char *test_vals[] = { "one", "two", "three" };
int i;
size_t u;
ConfNode *parent = ConfNodeNew();
ConfNode *child;
for (i = 0; i < sizeof(test_vals)/sizeof(test_vals[0]); i++) {
for (u = 0; u < sizeof(test_vals)/sizeof(test_vals[0]); u++) {
child = ConfNodeNew();
child->name = strdup(test_vals[i]);
child->val = strdup(test_vals[i]);
child->name = strdup(test_vals[u]);
child->val = strdup(test_vals[u]);
TAILQ_INSERT_TAIL(&parent->head, child, next);
}
@ -776,16 +776,16 @@ static int
ConfNodeLookupChildValueTest(void)
{
char *test_vals[] = { "one", "two", "three" };
int i;
size_t u;
ConfNode *parent = ConfNodeNew();
ConfNode *child;
const char *value;
for (i = 0; i < sizeof(test_vals)/sizeof(test_vals[0]); i++) {
for (u = 0; u < sizeof(test_vals)/sizeof(test_vals[0]); u++) {
child = ConfNodeNew();
child->name = strdup(test_vals[i]);
child->val = strdup(test_vals[i]);
child->name = strdup(test_vals[u]);
child->val = strdup(test_vals[u]);
TAILQ_INSERT_TAIL(&parent->head, child, next);
}

@ -528,7 +528,7 @@ static void SCPerfCopyCounterValue(SCPCAElem *pcae, int reset_lc)
double d_temp = 0;
uint64_t ui64_temp = 0;
int i = 0;
uint64_t u = 0;
pc = pcae->pc;
switch (pc->value->type) {
@ -536,7 +536,7 @@ static void SCPerfCopyCounterValue(SCPCAElem *pcae, int reset_lc)
ui64_temp = pcae->ui64_cnt;
if (pc->type_q->type & SC_PERF_TYPE_Q_AVERAGE) {
for (i = 0; i < pcae->wrapped_syncs; i++)
for (u = 0; u < pcae->wrapped_syncs; u++)
ui64_temp /= ULONG_MAX;
if (pcae->syncs != 0)
@ -561,7 +561,7 @@ static void SCPerfCopyCounterValue(SCPCAElem *pcae, int reset_lc)
d_temp = pcae->d_cnt;
if (pc->type_q->type & SC_PERF_TYPE_Q_AVERAGE) {
for (i = 0; i < pcae->wrapped_syncs; i++)
for (u = 0; u < pcae->wrapped_syncs; u++)
d_temp /= ULONG_MAX;
if (pcae->syncs != 0)
@ -671,7 +671,7 @@ static int SCPerfOutputCounterFileIface()
struct timeval tval;
struct tm *tms;
int i = 0;
uint32_t u = 0;
int flag = 0;
if (sc_perf_op_ctx->fp == NULL) {
@ -697,8 +697,8 @@ static int SCPerfOutputCounterFileIface()
"---------------------\n");
if (sc_perf_op_ctx->club_tm == 0) {
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
for (u = 0; u < TVT_MAX; u++) {
tv = tv_root[u];
while (tv != NULL) {
SCMutexLock(&tv->sc_perf_pctx.m);
@ -712,13 +712,13 @@ static int SCPerfOutputCounterFileIface()
switch (pc->value->type) {
case SC_PERF_TYPE_UINT64:
SCPerfOutputCalculateCounterValue(pc_heads[i], &ui64_temp);
SCPerfOutputCalculateCounterValue(pc_heads[u], &ui64_temp);
fprintf(sc_perf_op_ctx->fp, "%-25s | %-25s | %-" PRIu64 "\n",
pc->name->cname, pc->name->tm_name, ui64_temp);
break;
case SC_PERF_TYPE_DOUBLE:
SCPerfOutputCalculateCounterValue(pc_heads[i], &double_temp);
SCPerfOutputCalculateCounterValue(pc_heads[u], &double_temp);
fprintf(sc_perf_op_ctx->fp, "%-25s | %-25s | %-lf\n",
pc->name->cname, pc->name->tm_name, double_temp);
@ -745,13 +745,13 @@ static int SCPerfOutputCounterFileIface()
}
memset(pc_heads, 0, pctmi->size * sizeof(SCPerfCounter **));
for (i = 0; i < pctmi->size; i++) {
pc_heads[i] = pctmi->head[i]->head;
for (u = 0; u < pctmi->size; u++) {
pc_heads[u] = pctmi->head[u]->head;
SCMutexLock(&pctmi->head[i]->m);
SCMutexLock(&pctmi->head[u]->m);
while(strcmp(pctmi->tm_name, pc_heads[i]->name->tm_name))
pc_heads[i] = pc_heads[i]->next;
while(strcmp(pctmi->tm_name, pc_heads[u]->name->tm_name))
pc_heads[u] = pc_heads[u]->next;
}
flag = 1;
@ -760,23 +760,23 @@ static int SCPerfOutputCounterFileIface()
double_result = 0;
pc = pc_heads[0];
for (i = 0; i < pctmi->size; i++) {
for (u = 0; u < pctmi->size; u++) {
switch (pc->value->type) {
case SC_PERF_TYPE_UINT64:
SCPerfOutputCalculateCounterValue(pc_heads[i], &ui64_temp);
SCPerfOutputCalculateCounterValue(pc_heads[u], &ui64_temp);
ui64_result += ui64_temp;
break;
case SC_PERF_TYPE_DOUBLE:
SCPerfOutputCalculateCounterValue(pc_heads[i], &double_temp);
SCPerfOutputCalculateCounterValue(pc_heads[u], &double_temp);
double_result += double_temp;
break;
}
pc_heads[i] = pc_heads[i]->next;
pc_heads[u] = pc_heads[u]->next;
if (pc_heads[i] == NULL ||
if (pc_heads[u] == NULL ||
strcmp(pctmi->tm_name, pc_heads[0]->name->tm_name))
flag = 0;
}
@ -798,8 +798,8 @@ static int SCPerfOutputCounterFileIface()
}
}
for (i = 0; i < pctmi->size; i++)
SCMutexUnlock(&pctmi->head[i]->m);
for (u = 0; u < pctmi->size; u++)
SCMutexUnlock(&pctmi->head[u]->m);
pctmi = pctmi->next;
@ -1081,7 +1081,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
SCPerfClubTMInst *prev = NULL;
SCPerfClubTMInst *temp = NULL;
SCPerfContext **hpctx = NULL;
int i = 0;
uint32_t u = 0;
if (tm_name == NULL || pctx == NULL) {
SCLogDebug("supplied argument(s) to SCPerfAddToClubbedTMTable NULL");
@ -1125,8 +1125,8 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
}
hpctx = pctmi->head;
for (i = 0; i < pctmi->size; i++) {
if (hpctx[i] != pctx)
for (u = 0; u < pctmi->size; u++) {
if (hpctx[u] != pctx)
continue;
SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
@ -1138,10 +1138,10 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
hpctx = pctmi->head;
hpctx[pctmi->size] = pctx;
for (i = pctmi->size - 1; i >= 0; i--) {
if (pctx->curr_id <= hpctx[i]->curr_id) {
hpctx[i + 1] = hpctx[i];
hpctx[i] = pctx;
for (u = pctmi->size - 1; u > 0; u--) {
if (pctx->curr_id <= hpctx[u]->curr_id) {
hpctx[u + 1] = hpctx[u];
hpctx[u] = pctx;
continue;
}
break;

@ -31,8 +31,9 @@ inline uint16_t IPV4CalculateChecksum(uint16_t *pkt, uint16_t hlen)
hlen -= 20;
pkt += 10;
if (hlen == 0)
if (hlen == 0) {
;
}
if (hlen == 4)
csum += pkt[0] + pkt[1];
else if (hlen == 8)

@ -103,7 +103,7 @@ int DetectBytejumpMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
}
/* Verify the to-be-extracted data is within the packet */
if ((ptr < p->pkt) || (len < 0) || (data->nbytes > len)) {
if (ptr < p->pkt || data->nbytes > len) {
printf("DetectBytejumpMatch: Data not within packet "
"pkt=%p, ptr=%p, len=%d, nbytes=%d\n",
p->pkt, ptr, len, data->nbytes);

@ -107,7 +107,7 @@ int DetectBytetestMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
/* Validate that the to-be-extracted is within the packet
* \todo Should this validate it is in the *payload*?
*/
if ((ptr < p->pkt) || (len < 0) || (data->nbytes > len)) {
if (ptr < p->pkt || data->nbytes > len) {
SCLogDebug("Data not within packet pkt=%p, ptr=%p, len=%d, nbytes=%d",
p->pkt, ptr, len, data->nbytes);
return 0;

@ -543,7 +543,7 @@ DoDetectContent(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signat
SCLogDebug("isdataat: payload_len: %u, used %u, rest %u, isdataat? %u", p->payload_len, (m->offset + co->content_len),p->payload_len - (m->offset + co->content_len), co->isdataat);
if ( ((p->payload_len - (m->offset + co->content_len)) < co->isdataat) )
if ((uint32_t)(p->payload_len - (m->offset + co->content_len)) < co->isdataat)
match = 0;
if (match) {

@ -24,9 +24,9 @@
#define CHUNK_UPDATED_WITHIN 0x10
typedef struct DetectContentData_ {
uint8_t *content;
uint8_t content_len;
uint32_t id;
uint8_t *content; /**< ptr to chunk of memory containing the pattern */
uint8_t content_len;/**< length of the pattern (and size of the memory) */
uint32_t id; /**< unique pattern id */
uint8_t negated;

@ -72,7 +72,7 @@ static inline DetectDceOpnumRange *DetectDceOpnumAllocDetectDceOpnumRange(void)
exit(EXIT_FAILURE);
}
memset(dor, 0, sizeof(DetectDceOpnumRange));
dor->range1 = dor->range2 = -1;
dor->range1 = dor->range2 = DCE_OPNUM_RANGE_UNINITIALIZED;
return dor;
}
@ -138,20 +138,20 @@ static inline DetectDceOpnumData *DetectDceOpnumArgParse(const char *arg)
dor = DetectDceOpnumAllocDetectDceOpnumRange();
if ( (hyphen_token = index(dup_str_temp, '-')) != NULL) {
if ((hyphen_token = index(dup_str_temp, '-')) != NULL) {
hyphen_token[0] = '\0';
hyphen_token++;
dor->range1 = atoi(dup_str_temp);
if (dor->range1 > 65535)
if (dor->range1 > DCE_OPNUM_RANGE_MAX)
goto error;
dor->range2 = atoi(hyphen_token);
if (dor->range2 > 65535)
if (dor->range2 > DCE_OPNUM_RANGE_MAX)
goto error;
if (dor->range1 > dor->range2)
goto error;
}
dor->range1 = atoi(dup_str_temp);
if (dor->range1 > 65535)
if (dor->range1 > DCE_OPNUM_RANGE_MAX)
goto error;
if (prev_dor == NULL) {
@ -171,16 +171,16 @@ static inline DetectDceOpnumData *DetectDceOpnumArgParse(const char *arg)
hyphen_token[0] = '\0';
hyphen_token++;
dor->range1 = atoi(dup_str);
if (dor->range1 > 65535)
if (dor->range1 > DCE_OPNUM_RANGE_MAX)
goto error;
dor->range2 = atoi(hyphen_token);
if (dor->range2 > 65535)
if (dor->range2 > DCE_OPNUM_RANGE_MAX)
goto error;
if (dor->range1 > dor->range2)
goto error;
}
dor->range1 = atoi(dup_str);
if (dor->range1 > 65535)
if (dor->range1 > DCE_OPNUM_RANGE_MAX)
goto error;
if (prev_dor == NULL) {
@ -319,7 +319,7 @@ static int DetectDceOpnumTestParse02(void)
if (dod == NULL)
goto end;
dor = dod->range;
result &= (dor->range1 == 12 && dor->range2 == -1);
result &= (dor->range1 == 12 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next == NULL);
}
@ -379,7 +379,7 @@ static int DetectDceOpnumTestParse04(void)
goto end;
dor = dor->next;
result &= (dor->range1 == 24 && dor->range2 == -1);
result &= (dor->range1 == 24 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
@ -397,13 +397,13 @@ static int DetectDceOpnumTestParse04(void)
goto end;
dor = dor->next;
result &= (dor->range1 == 62 && dor->range2 == -1);
result &= (dor->range1 == 62 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 25 && dor->range2 == -1);
result &= (dor->range1 == 25 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
@ -437,43 +437,43 @@ static int DetectDceOpnumTestParse05(void)
if (dod == NULL)
goto end;
dor = dod->range;
result &= (dor->range1 == 1 && dor->range2 == -1);
result &= (dor->range1 == 1 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 2 && dor->range2 == -1);
result &= (dor->range1 == 2 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 3 && dor->range2 == -1);
result &= (dor->range1 == 3 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 4 && dor->range2 == -1);
result &= (dor->range1 == 4 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 5 && dor->range2 == -1);
result &= (dor->range1 == 5 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 6 && dor->range2 == -1);
result &= (dor->range1 == 6 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
result &= (dor->next != NULL);
if (result == 0)
goto end;
dor = dor->next;
result &= (dor->range1 == 7 && dor->range2 == -1);
result &= (dor->range1 == 7 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
if (result == 0)
goto end;
}
@ -571,7 +571,7 @@ static int DetectDceOpnumTestParse07(void)
goto end;
dor = dor->next;
result &= (dor->range1 == 9 && dor->range2 == -1);
result &= (dor->range1 == 9 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED);
if (result == 0)
goto end;
}

@ -11,6 +11,9 @@ typedef struct DetectDceOpnumRange_ {
struct DetectDceOpnumRange_ *next;
} DetectDceOpnumRange;
#define DCE_OPNUM_RANGE_MAX 65535
#define DCE_OPNUM_RANGE_UNINITIALIZED 100000
typedef struct DetectDceOpnumData_ {
DetectDceOpnumRange *range;
} DetectDceOpnumData;

@ -639,13 +639,13 @@ static int DetectAddressParseString(DetectAddress *dd, char *str)
mask++;
uint32_t ip4addr = 0;
uint32_t netmask = 0;
int i = 0;
size_t u = 0;
if ((strchr (mask, '.')) == NULL) {
/* 1.2.3.4/24 format */
for(i = 0; i < strlen(mask); i++) {
if(!isdigit(mask[i]))
for (u = 0; u < strlen(mask); u++) {
if(!isdigit(mask[u]))
goto error;
}
@ -916,7 +916,8 @@ error:
int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
int negate)
{
int i, x;
size_t x = 0;
size_t u = 0;
int o_set = 0, n_set = 0, d_set = 0;
int depth = 0;
size_t size = strlen(s);
@ -926,20 +927,20 @@ int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
SCLogDebug("s %s negate %s", s, negate ? "true" : "false");
for (i = 0, x = 0; i < size && x < sizeof(address); i++) {
address[x] = s[i];
for (u = 0, x = 0; u < size && x < sizeof(address); u++) {
address[x] = s[u];
x++;
if (!o_set && s[i] == '!') {
if (!o_set && s[u] == '!') {
n_set = 1;
x--;
} else if (s[i] == '[') {
} else if (s[u] == '[') {
if (!o_set) {
o_set = 1;
x = 0;
}
depth++;
} else if (s[i] == ']') {
} else if (s[u] == ']') {
if (depth == 1) {
address[x - 1] = '\0';
x = 0;
@ -949,7 +950,7 @@ int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
n_set = 0;
}
depth--;
} else if (depth == 0 && s[i] == ',') {
} else if (depth == 0 && s[u] == ',') {
if (o_set == 1) {
o_set = 0;
} else if (d_set == 1) {
@ -988,9 +989,9 @@ int DetectAddressParse2(DetectAddressHead *gh, DetectAddressHead *ghn, char *s,
n_set = 0;
}
x = 0;
} else if (depth == 0 && s[i] == '$') {
} else if (depth == 0 && s[u] == '$') {
d_set = 1;
} else if (depth == 0 && i == size - 1) {
} else if (depth == 0 && u == size - 1) {
address[x] = '\0';
x = 0;

@ -982,7 +982,8 @@ error:
*/
static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
int negate) {
int i, x;
size_t u = 0;
size_t x = 0;
int o_set = 0, n_set = 0, d_set = 0;
int range = 0;
int depth = 0;
@ -993,27 +994,27 @@ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
SCLogDebug("head %p, *head %p, negate %d", head, *head, negate);
for (i = 0, x = 0; i < size && x < sizeof(address); i++) {
address[x] = s[i];
for (u = 0, x = 0; u < size && x < sizeof(address); u++) {
address[x] = s[u];
x++;
if (s[i] == ':')
if (s[u] == ':')
range = 1;
if (range == 1 && s[i] == '!') {
if (range == 1 && s[u] == '!') {
SCLogError(SC_NEGATED_VALUE_IN_PORT_RANGE,"Can't have a negated value in a range.");
return -1;
} else if (!o_set && s[i] == '!') {
} else if (!o_set && s[u] == '!') {
SCLogDebug("negation encountered");
n_set = 1;
x--;
} else if (s[i] == '[') {
} else if (s[u] == '[') {
if (!o_set) {
o_set = 1;
x = 0;
}
depth++;
} else if (s[i] == ']') {
} else if (s[u] == ']') {
if (depth == 1) {
address[x - 1] = '\0';
SCLogDebug("Parsed port from DetectPortParseDo - %s", address);
@ -1024,7 +1025,7 @@ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
}
depth--;
range = 0;
} else if (depth == 0 && s[i] == ',') {
} else if (depth == 0 && s[u] == ',') {
if (o_set == 1) {
o_set = 0;
} else if (d_set == 1) {
@ -1063,9 +1064,9 @@ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s,
}
x = 0;
range = 0;
} else if (depth == 0 && s[i] == '$') {
} else if (depth == 0 && s[u] == '$') {
d_set = 1;
} else if (depth == 0 && i == size-1) {
} else if (depth == 0 && u == size-1) {
range = 0;
address[x] = '\0';
SCLogDebug("%s", address);

@ -161,7 +161,7 @@ DetectIdData *DetectIdParse (char *idstr)
/* ok, fill the id data */
temp = atoi((char *)tmp_str);
if (temp > DETECT_IPID_MAX || temp < DETECT_IPID_MIN) {
if (temp > DETECT_IPID_MAX) {
SCLogDebug("detect-id: \"id\" option must be in "
"the range %u - %u\n",
DETECT_IPID_MIN, DETECT_IPID_MAX);

@ -145,16 +145,16 @@ DetectWindowData *DetectWindowParse (char *windowstr)
goto error;
}
args[0] = (char *)str_ptr;
/// Detect if it's negated
// Detect if it's negated
if(args[0][0]=='!')
wd->negated=1;
else
wd->negated=0;
#ifdef WINDOW_DEBUG
#ifdef WINDOW_DEBUG
if(wd->negated)
printf("detect-window: Negation: %s\n", windowstr);
#endif
#endif
if (ret > 2) {
res = pcre_get_substring((char *)windowstr, ov, MAX_SUBSTRINGS, 2, &str_ptr);
@ -164,16 +164,15 @@ DetectWindowData *DetectWindowParse (char *windowstr)
}
wd->size = atoi((char *)str_ptr);
/// Get the window size if it's a valid value (in packets, we should alert if this doesn't happend from decode)
if(wd->size<MIN_WINDOW_VALUE || wd->size>MAX_WINDOW_VALUE) //If greater than 1GB window
// Get the window size if it's a valid value (in packets, we should alert if this doesn't happend from decode)
if(wd->size > MAX_WINDOW_VALUE)
{
goto error;
}
#ifdef WINDOW_DEBUG
#ifdef WINDOW_DEBUG
printf("detect-window: window size-> %u\n", wd->size);
#endif
#endif
}
}

@ -231,9 +231,9 @@ int DetectLoadSigFile(DetectEngineCtx *de_ctx, char *sig_file) {
return -1;
}
char line[8192] = "";
int offset = 0;
size_t offset = 0;
while(fgets(line + offset, (int)sizeof(line) - offset, fp) != NULL) {
int len = strlen(line);
size_t len = strlen(line);
/* ignore comments and empty lines */
if (line[0] == '\n' || line[0] == ' ' || line[0] == '#' || line[0] == '\t')
@ -2642,7 +2642,7 @@ void DbgSghContainsSig(DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid)
int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
DetectAddressHead *global_dst_gh = NULL;
DetectAddress *global_src_gr = NULL, *global_dst_gr = NULL;
int i;
uint32_t u;
printf("* Building signature grouping structure, stage 5: print...\n");
@ -2688,8 +2688,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ", maxlen %" PRIu32 ")", dp->sh->sig_cnt, dp->sh->mpm_content_maxlen);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2719,8 +2719,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2762,8 +2762,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2793,8 +2793,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2836,8 +2836,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2867,8 +2867,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif
@ -2898,8 +2898,8 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
printf(" (sigs %" PRIu32 ")", dp->sh->sig_cnt);
#ifdef PRINTSIGS
printf(" - ");
for (i = 0; i < dp->sh->sig_cnt; i++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[i]];
for (u = 0; u < dp->sh->sig_cnt; u++) {
Signature *s = de_ctx->sig_array[dp->sh->match_array[u]];
printf("%" PRIu32 " ", s->id);
}
#endif

@ -184,7 +184,7 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
timeout, (intmax_t)f->lastts.tv_sec + timeout, (intmax_t)ts->tv_sec);
/* do the timeout check */
if ((f->lastts.tv_sec + timeout) >= ts->tv_sec) {
if ((int32_t)(f->lastts.tv_sec + timeout) >= ts->tv_sec) {
SCMutexUnlock(&f->fb->m);
SCMutexUnlock(&f->m);
SCLogDebug("timeout check failed");

@ -41,7 +41,7 @@ typedef struct PcapFileThreadVars_
Packet *in_p;
} PcapFileThreadVars;
static PcapFileGlobalVars pcap_g = { NULL, NULL, };
static PcapFileGlobalVars pcap_g = { NULL, NULL, 0, };
TmEcode ReceivePcapFile(ThreadVars *, Packet *, void *, PacketQueue *);
TmEcode ReceivePcapFileThreadInit(ThreadVars *, void *, void **);

@ -295,7 +295,9 @@ int main(int argc, char **argv)
char *sig_file = NULL;
int nfq_id = 0;
char *conf_filename = NULL;
#ifdef UNITTESTS
char *regex_arg = NULL;
#endif
int dump_config = 0;
int list_unittests = 0;
int daemon = 0;

@ -77,8 +77,9 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
fclose(lf_ctx->fp);
SCMutexUnlock(&lf_ctx->fp_mutex);
}
if (lf_ctx->config_file != NULL);
if (lf_ctx->config_file != NULL) {
free(lf_ctx->config_file);
}
free(lf_ctx);
ret=1;
}

@ -107,7 +107,12 @@ uint32_t BloomFilterMemorySize(BloomFilter *bf) {
return (sizeof(BloomFilter) + (bf->bitarray_size/8) + 1);
}
static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) {
/*
* ONLY TESTS BELOW THIS COMMENT
*/
#ifdef UNITTESTS
static uint32_t BloomFilterTestHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) {
uint8_t *d = (uint8_t *)data;
uint32_t i;
uint32_t hash = 0;
@ -123,13 +128,8 @@ static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t h
return hash;
}
/*
* ONLY TESTS BELOW THIS COMMENT
*/
#ifdef UNITTESTS
static int BloomFilterTestInit01 (void) {
BloomFilter *bf = BloomFilterInit(1024, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return 0;
@ -149,11 +149,11 @@ static int BloomFilterTestInit02 (void) {
static int BloomFilterTestInit03 (void) {
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return 0;
if (bf->Hash == BloomHash)
if (bf->Hash == BloomFilterTestHash)
result = 1;
BloomFilterFree(bf);
@ -161,7 +161,7 @@ static int BloomFilterTestInit03 (void) {
}
static int BloomFilterTestInit04 (void) {
BloomFilter *bf = BloomFilterInit(1024, 0, BloomHash);
BloomFilter *bf = BloomFilterInit(1024, 0, BloomFilterTestHash);
if (bf == NULL)
return 1;
@ -170,7 +170,7 @@ static int BloomFilterTestInit04 (void) {
}
static int BloomFilterTestInit05 (void) {
BloomFilter *bf = BloomFilterInit(0, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(0, 4, BloomFilterTestHash);
if (bf == NULL)
return 1;
@ -180,7 +180,7 @@ static int BloomFilterTestInit05 (void) {
static int BloomFilterTestAdd01 (void) {
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return 0;
@ -197,7 +197,7 @@ end:
static int BloomFilterTestAdd02 (void) {
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return 0;
@ -214,7 +214,7 @@ end:
static int BloomFilterTestFull01 (void) {
int result = 0;
BloomFilter *bf = BloomFilterInit(32, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash);
if (bf == NULL)
goto end;
@ -235,7 +235,7 @@ end:
static int BloomFilterTestFull02 (void) {
int result = 0;
BloomFilter *bf = BloomFilterInit(32, 4, BloomHash);
BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash);
if (bf == NULL)
goto end;

@ -41,7 +41,7 @@ inline int ByteExtractUint64(uint64_t *res, int e, uint16_t len, const uint8_t *
int ret;
/* Uint64 is limited to 8 bytes */
if ((len < 0) || (len > 8)) {
if (len > 8) {
/** \todo Need standard return values */
return -1;
}
@ -62,7 +62,7 @@ inline int ByteExtractUint32(uint32_t *res, int e, uint16_t len, const uint8_t *
int ret;
/* Uint32 is limited to 4 bytes */
if ((len < 0) || (len > 4)) {
if (len > 4) {
/** \todo Need standard return values */
return -1;
}
@ -83,7 +83,7 @@ inline int ByteExtractUint16(uint16_t *res, int e, uint16_t len, const uint8_t *
int ret;
/* Uint16 is limited to 2 bytes */
if ((len < 0) || (len > 2)) {
if (len > 2) {
/** \todo Need standard return values */
return -1;
}

@ -636,7 +636,8 @@ int SCLogMatchFDFilter(const char *function)
{
SCLogFDFilterThreadList *thread_list = NULL;
pid_t self = syscall(SYS_gettid);
// pid_t self = syscall(SYS_gettid);
pthread_t self = pthread_self();
#ifndef DEBUG
return 1;
@ -659,7 +660,7 @@ int SCLogMatchFDFilter(const char *function)
thread_list = sc_log_fd_filters_tl;
while (thread_list != NULL) {
if (self == thread_list->t) {
if (pthread_equal(self, thread_list->t)) {
if (thread_list->entered > 0) {
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 1;
@ -693,7 +694,8 @@ int SCLogCheckFDFilterEntry(const char *function)
SCLogFDFilterThreadList *thread_list_prev = NULL;
SCLogFDFilterThreadList *thread_list_temp = NULL;
pid_t self = syscall(SYS_gettid);
//pid_t self = syscall(SYS_gettid);
pthread_t self = pthread_self();
if (sc_log_module_initialized != 1) {
printf("Logging module not initialized. Call SCLogInitLogModule() "
@ -726,7 +728,7 @@ int SCLogCheckFDFilterEntry(const char *function)
while (thread_list != NULL) {
thread_list_temp = thread_list;
if (self == thread_list->t)
if (pthread_equal(self, thread_list->t))
break;
thread_list = thread_list->next;
@ -771,7 +773,8 @@ void SCLogCheckFDFilterExit(const char *function)
SCLogFDFilterThreadList *thread_list = NULL;
pid_t self = syscall(SYS_gettid);
//pid_t self = syscall(SYS_gettid);
pthread_t self = pthread_self();
if (sc_log_module_initialized != 1) {
printf("Logging module not initialized. Call SCLogInitLogModule() "
@ -801,7 +804,7 @@ void SCLogCheckFDFilterExit(const char *function)
thread_list = sc_log_fd_filters_tl;
while (thread_list != NULL) {
if (self == thread_list->t)
if (pthread_equal(self, thread_list->t))
break;
thread_list = thread_list->next;

@ -66,6 +66,7 @@ typedef struct SCLogFGFilterFile_ {
typedef struct SCLogFDFilterThreadList_ {
int entered;
pthread_t t;
// pid_t t;
struct SCLogFDFilterThreadList_ *next;
} SCLogFDFilterThreadList;

@ -34,6 +34,7 @@
/* holds the string-enum mapping for the enums held in the table SCLogLevel */
SCEnumCharMap sc_log_level_map[ ] = {
{ "Not set", SC_LOG_NOTSET},
{ "None", SC_LOG_NONE },
{ "Emergency", SC_LOG_EMERGENCY },
{ "Alert", SC_LOG_ALERT },
@ -215,7 +216,7 @@ void SCLogOutputBuffer(SCLogLevel log_level, char *msg)
op_iface_ctx = sc_log_config->op_ifaces;
while (op_iface_ctx != NULL) {
if (log_level != -1 && log_level > op_iface_ctx->log_level) {
if (log_level != SC_LOG_NOTSET && log_level > op_iface_ctx->log_level) {
op_iface_ctx = op_iface_ctx->next;
continue;
}
@ -537,7 +538,7 @@ static inline SCLogOPIfaceCtx *SCLogInitFileOPIface(const char *file,
* \retval iface_ctx Pointer to the console output interface context created
*/
static inline SCLogOPIfaceCtx *SCLogInitConsoleOPIface(const char *log_format,
int log_level)
SCLogLevel log_level)
{
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
@ -572,7 +573,7 @@ static inline SCLogOPIfaceCtx *SCLogInitConsoleOPIface(const char *log_format,
*/
static inline SCLogOPIfaceCtx *SCLogInitSyslogOPIface(int facility,
const char *log_format,
int log_level)
SCLogLevel log_level)
{
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
@ -642,7 +643,7 @@ static inline void SCLogFreeLogOPIfaceCtx(SCLogOPIfaceCtx *iface_ctx)
*/
static inline void SCLogSetLogLevel(SCLogInitData *sc_lid, SCLogConfig *sc_lc)
{
SCLogLevel log_level = -1;
SCLogLevel log_level = SC_LOG_NOTSET;
const char *s = NULL;
if (sc_lid != NULL)
@ -654,7 +655,7 @@ static inline void SCLogSetLogLevel(SCLogInitData *sc_lid, SCLogConfig *sc_lc)
}
/* deal with the global_log_level to be used */
if (log_level >= 0 && log_level < SC_LOG_LEVEL_MAX)
if (log_level > SC_LOG_NOTSET && log_level < SC_LOG_LEVEL_MAX)
sc_lc->log_level = log_level;
else {
sc_lc->log_level = SC_LOG_DEF_LOG_LEVEL;
@ -758,14 +759,14 @@ static inline void SCLogSetOPIface(SCLogInitData *sc_lid, SCLogConfig *sc_lc)
switch (op_iface) {
case SC_LOG_OP_IFACE_CONSOLE:
op_ifaces_ctx = SCLogInitConsoleOPIface(NULL, -1);
op_ifaces_ctx = SCLogInitConsoleOPIface(NULL, SC_LOG_LEVEL_MAX);
break;
case SC_LOG_OP_IFACE_FILE:
s = getenv(SC_LOG_ENV_LOG_FILE);
if (s == NULL)
s = SCLogGetLogFilename(SC_LOG_DEF_LOG_FILE);
op_ifaces_ctx = SCLogInitFileOPIface(s, NULL, -1);
op_ifaces_ctx = SCLogInitFileOPIface(s, NULL, SC_LOG_LEVEL_MAX);
break;
case SC_LOG_OP_IFACE_SYSLOG:
s = getenv(SC_LOG_ENV_LOG_FACILITY);
@ -949,7 +950,7 @@ SCLogOPIfaceCtx *SCLogInitOPIfaceCtx(const char *iface_name,
"is invalid. Defaulting to not specifing an override\n",
iface_name);
#endif
log_level = -1;
log_level = SC_LOG_NOTSET;
}
switch (iface) {
@ -1068,7 +1069,7 @@ void SCLogInitLogModuleIfEnvSet(void)
SCLogOPIfaceCtx *op_ifaces_ctx = NULL;
int op_iface = 0;
char *format = NULL;
SCLogLevel log_level = -1;
SCLogLevel log_level = SC_LOG_NOTSET;
/* sc_log_config is a global variable */
if ( (sc_log_config = malloc(sizeof(SCLogConfig))) == NULL) {

@ -29,6 +29,7 @@
* \brief The various log levels
*/
typedef enum {
SC_LOG_NOTSET = -1,
SC_LOG_NONE = 0,
SC_LOG_EMERGENCY,
SC_LOG_ALERT,

@ -560,7 +560,7 @@ static void B2gPrepareScanHash(MpmCtx *mpm_ctx) {
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (sizeof(BloomFilter *) * ctx->scan_hash_size);
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
B2gHashItem *hi = ctx->scan_hash[h];
if (hi == NULL)
@ -666,7 +666,7 @@ static void B2gPrepareSearchHash(MpmCtx *mpm_ctx) {
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (sizeof(BloomFilter *) * ctx->search_hash_size);
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
B2gHashItem *hi = ctx->search_hash[h];
if (hi == NULL)
@ -706,7 +706,7 @@ int B2gBuildScanMatchArray(MpmCtx *mpm_ctx) {
memset(ctx->scan_B2G,0, B2G_HASHSIZE * sizeof(B2G_TYPE));
uint32_t j;
int a;
uint32_t a;
/* fill the match array */
for (j = 0; j <= (ctx->scan_m - B2G_Q); j++) {
@ -741,7 +741,7 @@ int B2gBuildSearchMatchArray(MpmCtx *mpm_ctx) {
memset(ctx->search_B2G,0, B2G_HASHSIZE * sizeof(B2G_TYPE));
uint32_t j;
int a;
uint32_t a;
/* fill the match array */
for (j = 0; j <= (ctx->search_m - B2G_Q); j++) {
@ -983,7 +983,7 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_bloom) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_bloom[h] == NULL)
continue;
@ -1001,7 +1001,7 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_hash[h] == NULL)
continue;
@ -1015,7 +1015,7 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->search_bloom) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_bloom[h] == NULL)
continue;
@ -1033,7 +1033,7 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->search_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_hash[h] == NULL)
continue;
@ -1147,7 +1147,7 @@ uint32_t B2gScanBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatc
if (buflen < ctx->scan_m)
return 0;
while (pos <= (buflen - B2G_Q + 1)) {
while (pos <= (uint32_t)(buflen - B2G_Q + 1)) {
uint16_t h = B2G_HASH16(u8_tolower(buf[pos - 1]),u8_tolower(buf[pos]));
d = ctx->scan_B2G[h];
@ -1159,7 +1159,7 @@ uint32_t B2gScanBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatc
do {
j = j - 1;
if (d >= (1 << (ctx->scan_m - 1))) {
if (d >= (uint32_t)(1 << (ctx->scan_m - 1))) {
if (j > first) pos = j;
else {
/* get our patterns from the hash */
@ -1542,7 +1542,7 @@ uint32_t B2gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
if (buflen < ctx->search_m)
SCReturnUInt(0);
while (pos <= (buflen - B2G_Q + 1)) {
while (pos <= (uint32_t)(buflen - B2G_Q + 1)) {
uint16_t h = B2G_HASH16(u8_tolower(buf[pos - 1]),u8_tolower(buf[pos]));
d = ctx->search_B2G[h];
@ -1553,7 +1553,7 @@ uint32_t B2gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
do {
j = j - 1;
if (d >= (1 << (ctx->search_m - 1))) {
if (d >= (uint32_t)(1 << (ctx->search_m - 1))) {
if (j > first) pos = j;
else {
/* get our patterns from the hash */

@ -536,7 +536,7 @@ static void B3gPrepareScanHash(MpmCtx *mpm_ctx) {
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (sizeof(BloomFilter *) * ctx->scan_hash_size);
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
B3gHashItem *hi = ctx->scan_hash[h];
if (hi == NULL)
@ -670,7 +670,7 @@ static void B3gPrepareSearchHash(MpmCtx *mpm_ctx) {
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (sizeof(BloomFilter *) * ctx->search_hash_size);
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
B3gHashItem *hi = ctx->search_hash[h];
if (hi == NULL)
@ -711,7 +711,7 @@ int B3gBuildScanMatchArray(MpmCtx *mpm_ctx) {
memset(ctx->scan_B3G,0, B3G_HASHSIZE * sizeof(B3G_TYPE));
uint32_t j;
int a;
uint32_t a;
/* fill the match array */
for (j = 0; j <= (ctx->scan_m - B3G_Q); j++) {
@ -745,7 +745,7 @@ int B3gBuildSearchMatchArray(MpmCtx *mpm_ctx) {
memset(ctx->search_B3G,0, B3G_HASHSIZE * sizeof(B3G_TYPE));
uint32_t j;
int a;
uint32_t a;
/* fill the match array */
for (j = 0; j <= (ctx->search_m - B3G_Q); j++) {
@ -986,7 +986,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_bloom) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_bloom[h] == NULL)
continue;
@ -1004,7 +1004,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_hash[h] == NULL)
continue;
@ -1017,7 +1017,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->scan_hash_size);
}
if (ctx->scan_hash2) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_hash2[h] == NULL)
continue;
@ -1031,7 +1031,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->search_bloom) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_bloom[h] == NULL)
continue;
@ -1049,7 +1049,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->search_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_hash[h] == NULL)
continue;
@ -1062,7 +1062,7 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) {
mpm_ctx->memory_size -= (sizeof(B3gHashItem) * ctx->search_hash_size);
}
if (ctx->search_hash2) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_hash2[h] == NULL)
continue;
@ -1171,7 +1171,7 @@ uint32_t B3gScanBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatc
if (buflen < ctx->scan_m)
return 0;
while (pos <= (buflen - B3G_Q + 1)) {
while (pos <= (uint32_t)(buflen - B3G_Q + 1)) {
uint16_t h = B3G_HASH(u8_tolower(buf[pos - 1]), u8_tolower(buf[pos]),u8_tolower(buf[pos + 1]));
d = ctx->scan_B3G[h];
@ -1182,7 +1182,7 @@ uint32_t B3gScanBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatc
do {
j = j - 1;
if (d >= (1 << (ctx->scan_m - 1))) {
if (d >= (uint32_t)(1 << (ctx->scan_m - 1))) {
if (j > first) pos = j;
else {
/* get our patterns from the hash */
@ -1584,7 +1584,7 @@ uint32_t B3gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
if (buflen < ctx->search_m)
return 0;
while (pos <= (buflen - B3G_Q + 1)) {
while (pos <= (uint32_t)(buflen - B3G_Q + 1)) {
uint16_t h = B3G_HASH(u8_tolower(buf[pos - 1]), u8_tolower(buf[pos]),u8_tolower(buf[pos + 1]));
d = ctx->search_B3G[h];
@ -1595,7 +1595,7 @@ uint32_t B3gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMa
do {
j = j - 1;
if (d >= (1 << (ctx->search_m - 1))) {
if (d >= (uint32_t)(1 << (ctx->search_m - 1))) {
if (j > first) pos = j;
else {
/* get our patterns from the hash */

@ -598,7 +598,7 @@ static void WmScanPrepareHash(MpmCtx *mpm_ctx) {
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += (sizeof(BloomFilter *) * ctx->scan_hash_size);
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
WmHashItem *hi = ctx->scan_hash[h];
if (hi == NULL)
@ -2234,7 +2234,7 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_bloom) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_bloom[h] == NULL)
continue;
@ -2252,7 +2252,7 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) {
}
if (ctx->scan_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->scan_hash_size; h++) {
if (ctx->scan_hash[h] == NULL)
continue;
@ -2290,7 +2290,7 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) {
}
#endif
if (ctx->search_hash) {
int h;
uint32_t h;
for (h = 0; h < ctx->search_hash_size; h++) {
if (ctx->search_hash[h] == NULL)
continue;

@ -42,9 +42,9 @@ int PmqSetup(PatternMatcherQueue *pmq, uint32_t maxid) {
* \param pmq Pattern matcher to be reset.
*/
void PmqReset(PatternMatcherQueue *pmq) {
int i;
for (i = 0; i < pmq->sig_id_array_cnt; i++) {
pmq->sig_bitarray[(pmq->sig_id_array[i] / 8)] &= ~(1<<(pmq->sig_id_array[i] % 8));
uint32_t u;
for (u = 0; u < pmq->sig_id_array_cnt; u++) {
pmq->sig_bitarray[(pmq->sig_id_array[u] / 8)] &= ~(1<<(pmq->sig_id_array[u] % 8));
}
pmq->sig_id_array_cnt = 0;
}
@ -255,7 +255,7 @@ MpmEndMatch *MpmAllocEndMatch (MpmCtx *ctx)
* \retval -1 if the type is not registered return -1
*/
int32_t MpmMatcherGetMaxPatternLength(uint16_t matcher) {
if (matcher < MPM_TABLE_SIZE && matcher >= 0)
if (matcher < MPM_TABLE_SIZE)
return mpm_table[matcher].max_pattern_length;
else
return -1;

@ -3,21 +3,22 @@
#include "suricata-common.h"
void PrintRawUriFp(FILE *fp, uint8_t *buf, uint32_t buflen) {
int i;
for (i = 0; i < buflen; i++) {
if (isprint(buf[i])) fprintf(fp, "%c", buf[i]);
else fprintf(fp, "\\x%02X", buf[i]);
uint32_t u;
for (u = 0; u < buflen; u++) {
if (isprint(buf[u])) fprintf(fp, "%c", buf[u]);
else fprintf(fp, "\\x%02X", buf[u]);
}
}
void PrintRawDataFp(FILE *fp, uint8_t *buf, uint32_t buflen) {
int i,ch = 0;
int ch = 0;
uint32_t u = 0;
for (i = 0; i < buflen; i+=16) {
fprintf(fp ," %04X ", i);
for (u = 0; u < buflen; u+=16) {
fprintf(fp ," %04X ", u);
ch = 0;
for (ch = 0; (i+ch) < buflen && ch < 16; ch++) {
fprintf(fp, "%02X ", (uint8_t)buf[i+ch]);
for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
fprintf(fp, "%02X ", (uint8_t)buf[u+ch]);
if (ch == 7) fprintf(fp, " ");
}
@ -32,8 +33,8 @@ void PrintRawDataFp(FILE *fp, uint8_t *buf, uint32_t buflen) {
for ( ; s < spaces; s++) fprintf(fp, " ");
}
for (ch = 0; (i+ch) < buflen && ch < 16; ch++) {
fprintf(fp, "%c", isprint((uint8_t)buf[i+ch]) ? (uint8_t)buf[i+ch] : '.');
for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
fprintf(fp, "%c", isprint((uint8_t)buf[u+ch]) ? (uint8_t)buf[u+ch] : '.');
if (ch == 7) fprintf(fp, " ");
if (ch == 15) fprintf(fp, "\n");

Loading…
Cancel
Save