Support #70 » 0001-Renaming-errors-naming-conventions.patch
src/app-layer-htp.c | ||
---|---|---|
if(r == STREAM_STATE_ERROR)
|
||
{
|
||
if (hstate->connp->last_error != NULL) {
|
||
SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request: "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error in parsing HTTP client request: "
|
||
"[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level,
|
||
hstate->connp->last_error->file, hstate->connp->last_error->line,
|
||
hstate->connp->last_error->msg);
|
||
} else {
|
||
SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error in parsing HTTP client request");
|
||
}
|
||
hstate->flags |= HTP_FLAG_STATE_ERROR;
|
||
hstate->flags &= ~HTP_FLAG_STATE_DATA;
|
||
... | ... | |
if (r == STREAM_STATE_ERROR)
|
||
{
|
||
if (hstate->connp->last_error != NULL) {
|
||
SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response: "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error in parsing HTTP server response: "
|
||
"[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level,
|
||
hstate->connp->last_error->file, hstate->connp->last_error->line,
|
||
hstate->connp->last_error->msg);
|
||
} else {
|
||
SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error in parsing HTTP server response");
|
||
}
|
||
hstate->flags = HTP_FLAG_STATE_ERROR;
|
||
ret = -1;
|
src/app-layer-parser.c | ||
---|---|---|
if (pstate->store_len == 0) {
|
||
int r = AlpStoreField(output, field_idx, input, size, /* static mem */0);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
(*offset) += size;
|
||
... | ... | |
int r = AlpStoreField(output, field_idx, pstate->store,
|
||
pstate->store_len, /* alloc mem */1);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
int r = AlpStoreField(output, field_idx, input, input_len, 0);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
int r = AlpStoreField(output, field_idx, pstate->store, pstate->store_len, 1);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
int r = AlpStoreField(output, field_idx, input, len, 0);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
(*offset) += (len + delim_len);
|
||
... | ... | |
int r = AlpStoreField(output, field_idx, pstate->store,
|
||
pstate->store_len, 1);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
pstate->store = NULL;
|
||
... | ... | |
int r = AlpStoreField(output, field_idx,
|
||
pstate->store, len, 1);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store "
|
||
"field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
uint32_t len = ptr - pstate->store;
|
||
int r = AlpStoreField(output, field_idx, pstate->store, len, 1);
|
||
if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "Failed to store field value");
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Failed to store field value");
|
||
SCReturnInt(-1);
|
||
}
|
||
pstate->store = NULL;
|
||
... | ... | |
inet_ntop(AF_INET, (const void*)&f->dst.addr_data32[0], dst,
|
||
sizeof (dst));
|
||
SCLogError(SC_ALPARSER_ERR, "Error occured in parsing \"%s\" app layer "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error occured in parsing \"%s\" app layer "
|
||
"protocol, using network protocol %"PRIu8", source IP "
|
||
"address %s, destination IP address %s, src port %"PRIu16" and "
|
||
"dst port %"PRIu16"", al_proto_table[ssn->alproto].name,
|
||
... | ... | |
inet_ntop(AF_INET6, (const void*)&f->dst.addr_data32, dst6,
|
||
sizeof (dst6));
|
||
SCLogError(SC_ALPARSER_ERR, "Error occured in parsing \"%s\" app layer "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "Error occured in parsing \"%s\" app layer "
|
||
"protocol, using network protocol %"PRIu8", source IPv6 "
|
||
"address %s, destination IPv6 address %s, src port %"PRIu16" and "
|
||
"dst port %"PRIu16"", al_proto_table[ssn->alproto].name,
|
src/app-layer-tls.c | ||
---|---|---|
pstate->parse_field = 0;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
pstate->parse_field = 1;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
pstate->parse_field = 2;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
pstate->parse_field = 0;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
pstate->parse_field = 1;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
pstate->parse_field = 2;
|
||
SCReturnInt(0);
|
||
} else if (r == -1) {
|
||
SCLogError(SC_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
SCLogError(SC_ERR_ALPARSER_ERR, "AlpParseFieldBySize failed, "
|
||
"r %d", r);
|
||
SCReturnInt(-1);
|
||
}
|
src/counters.c | ||
---|---|---|
if (snprintf(log_filename, PATH_MAX, "%s/%s", log_dir,
|
||
SC_PERF_DEFAULT_LOG_FILENAME) < 0) {
|
||
SCLogError(SC_SPRINTF_ERROR, "Sprintf Error");
|
||
SCLogError(SC_ERR_SPRINTF_ERROR, "Sprintf Error");
|
||
free(log_filename);
|
||
return NULL;
|
||
}
|
||
... | ... | |
/* init the lock used by SCPerfClubTMInst */
|
||
if (SCMutexInit(&sc_perf_op_ctx->pctmi_lock, NULL) != 0) {
|
||
SCLogError(SC_INITIALIZATION_ERROR, "error initializing pctmi mutex");
|
||
SCLogError(SC_ERR_INITIALIZATION_ERROR, "error initializing pctmi mutex");
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
... | ... | |
ret = pcre_exec(regex, regex_study, interval, strlen(interval), 0, 0, ov, 30);
|
||
if (ret < 0) {
|
||
SCLogWarning(SC_INVALID_ARGUMENTS, "Invalid Timebased interval");
|
||
SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "Invalid Timebased interval");
|
||
goto error;
|
||
}
|
||
... | ... | |
/* (SC_PERF_TYPE_MAX - 1) because we haven't implemented SC_PERF_TYPE_STR */
|
||
if ((type >= (SC_PERF_TYPE_MAX - 1)) || (type < 0)) {
|
||
SCLogError(SC_INVALID_ARGUMENTS, "Counters of type %" PRId32 " can't "
|
||
SCLogError(SC_ERR_INVALID_ARGUMENTS, "Counters of type %" PRId32 " can't "
|
||
"be registered", type);
|
||
return 0;
|
||
}
|
||
... | ... | |
exit(EXIT_FAILURE);
|
||
}
|
||
if (TmThreadSpawn(tv_wakeup) != 0) {
|
||
SCLogError(SC_THREAD_SPAWN_FAILED, "TmThreadSpawn failed for "
|
||
SCLogError(SC_ERR_THREAD_SPAWN_FAILED, "TmThreadSpawn failed for "
|
||
"SCPerfWakeupThread");
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
... | ... | |
exit(EXIT_FAILURE);
|
||
}
|
||
if (TmThreadSpawn(tv_mgmt) != 0) {
|
||
SCLogError(SC_THREAD_SPAWN_FAILED, "TmThreadSpawn failed for "
|
||
SCLogError(SC_ERR_THREAD_SPAWN_FAILED, "TmThreadSpawn failed for "
|
||
"SCPerfWakeupThread");
|
||
exit(EXIT_FAILURE);
|
||
}
|
src/defrag.c | ||
---|---|---|
}
|
||
else {
|
||
if (timeout < TIMEOUT_MIN) {
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"defrag: Timeout less than minimum allowed value.");
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
else if (timeout > TIMEOUT_MAX) {
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"defrag: Tiemout greater than maximum allowed value.");
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
... | ... | |
}
|
||
else {
|
||
/* Abort - should not happen. */
|
||
SCLogWarning(SC_INVALID_ARGUMENT, "Invalid address family, aborting.");
|
||
SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid address family, aborting.");
|
||
return NULL;
|
||
}
|
||
src/detect-bytetest.c | ||
---|---|---|
parse_regex = pcre_compile(PARSE_REGEX, opts, &eb, &eo, NULL);
|
||
if(parse_regex == NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at "
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at "
|
||
"offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
goto error;
|
||
}
|
||
... | ... | |
parse_regex_study = pcre_study(parse_regex, 0, &eb);
|
||
if(eb != NULL)
|
||
{
|
||
SCLogError(SC_PCRE_STUDY_FAILED, "pcre study failed: %s", eb);
|
||
SCLogError(SC_ERR_PCRE_STUDY_FAILED, "pcre study failed: %s", eb);
|
||
goto error;
|
||
}
|
||
return;
|
||
... | ... | |
SCLogDebug("No Numeric value");
|
||
return 0;
|
||
} else {
|
||
SCLogError(SC_INVALID_NUM_BYTES, "Error extracting %d "
|
||
SCLogError(SC_ERR_INVALID_NUM_BYTES, "Error extracting %d "
|
||
"bytes of string data: %d", data->nbytes, extbytes);
|
||
return -1;
|
||
}
|
||
... | ... | |
BYTE_LITTLE_ENDIAN : BYTE_BIG_ENDIAN;
|
||
extbytes = ByteExtractUint64(&val, endianness, data->nbytes, ptr);
|
||
if (extbytes != data->nbytes) {
|
||
SCLogError(SC_INVALID_NUM_BYTES, "Error extracting %d bytes "
|
||
SCLogError(SC_ERR_INVALID_NUM_BYTES, "Error extracting %d bytes "
|
||
"of numeric data: %d\n", data->nbytes, extbytes);
|
||
return -1;
|
||
}
|
||
... | ... | |
ret = pcre_exec(parse_regex, parse_regex_study, optstr,
|
||
strlen(optstr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 6 || ret > 10) {
|
||
SCLogError(SC_PCRE_PARSE_FAILED, "parse error, ret %" PRId32
|
||
SCLogError(SC_ERR_PCRE_PARSE_FAILED, "parse error, ret %" PRId32
|
||
", string %s", ret, optstr);
|
||
goto error;
|
||
}
|
||
... | ... | |
res = pcre_get_substring((char *)optstr, ov, MAX_SUBSTRINGS,
|
||
i + 1, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed "
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed "
|
||
"for arg %d", i + 1);
|
||
goto error;
|
||
}
|
src/detect-dce-iface.c | ||
---|---|---|
/* retrieve the iface uuid string. iface uuid is a compulsion in the keyword */
|
||
res = pcre_get_substring(arg, ov, MAX_SUBSTRINGS, 1, &pcre_sub_str);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
... | ... | |
* validations of the version number, wrt. the operator */
|
||
res = pcre_get_substring(arg, ov, MAX_SUBSTRINGS, 3, &pcre_sub_str);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
... | ... | |
/* now let us handle the operator supplied with the version number */
|
||
res = pcre_get_substring(arg, ov, MAX_SUBSTRINGS, 2, &pcre_sub_str);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
src/detect-dce-opnum.c | ||
---|---|---|
res = pcre_get_substring(arg, ov, MAX_SUBSTRINGS, 0, &pcre_sub_str);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
src/detect-depth.c | ||
---|---|---|
DetectContentData *cd = (DetectContentData *)pm->ctx;
|
||
if (cd == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "invalid argument");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid argument");
|
||
if (dubbed) free(str);
|
||
return -1;
|
||
}
|
src/detect-dsize.c | ||
---|---|---|
parse_regex = pcre_compile(PARSE_REGEX, opts, &eb, &eo, NULL);
|
||
if(parse_regex == NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED,"pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED,"pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
goto error;
|
||
}
|
||
parse_regex_study = pcre_study(parse_regex, 0, &eb);
|
||
if(eb != NULL)
|
||
{
|
||
SCLogError(SC_PCRE_STUDY_FAILED,"pcre study failed: %s", eb);
|
||
SCLogError(SC_ERR_PCRE_STUDY_FAILED,"pcre study failed: %s", eb);
|
||
goto error;
|
||
}
|
||
return;
|
||
... | ... | |
ret = pcre_exec(parse_regex, parse_regex_study, rawstr, strlen(rawstr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 3 || ret > 5) {
|
||
SCLogError(SC_PCRE_MATCH_FAILED,"Parse error %s", rawstr);
|
||
SCLogError(SC_ERR_PCRE_MATCH_FAILED,"Parse error %s", rawstr);
|
||
goto error;
|
||
}
|
||
... | ... | |
res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 1, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
mode = (char *)str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 2, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
value1 = (char *)str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 3, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
range = (char *)str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 4, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
value2 = (char *)str_ptr;
|
||
... | ... | |
if (strcmp("<>", range) == 0) {
|
||
if (strlen(mode) != 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"Range specified but mode also set");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Range specified but mode also set");
|
||
goto error;
|
||
}
|
||
dd->mode = DETECTDSIZE_RA;
|
||
... | ... | |
/** set the first dsize value */
|
||
if(ByteExtractStringUint16(&dd->dsize,10,strlen(value1),value1) <= 0){
|
||
SCLogError(SC_INVALID_ARGUMENT,"Invalid size value1:\"%s\"",value1);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size value1:\"%s\"",value1);
|
||
goto error;
|
||
}
|
||
/** set the second dsize value if specified */
|
||
if (strlen(value2) > 0) {
|
||
if (dd->mode != DETECTDSIZE_RA) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"Multiple dsize values specified but mode is not range");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Multiple dsize values specified but mode is not range");
|
||
goto error;
|
||
}
|
||
if(ByteExtractStringUint16(&dd->dsize2,10,strlen(value2),value2) <= 0){
|
||
SCLogError(SC_INVALID_ARGUMENT,"Invalid size value2:\"%s\"",value2);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size value2:\"%s\"",value2);
|
||
goto error;
|
||
}
|
||
if (dd->dsize2 <= dd->dsize){
|
||
SCLogError(SC_INVALID_ARGUMENT,"dsize2:%"PRIu16" <= dsize:%"PRIu16"",dd->dsize2,dd->dsize);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"dsize2:%"PRIu16" <= dsize:%"PRIu16"",dd->dsize2,dd->dsize);
|
||
goto error;
|
||
}
|
||
}
|
||
... | ... | |
dd = DetectDsizeParse(rawstr);
|
||
if (dd == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
|
||
goto error;
|
||
}
|
||
src/detect-engine-port.c | ||
---|---|---|
/** parse the address */
|
||
ad = PortParse(s);
|
||
if (ad == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"PortParse error \"%s\"",s);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"PortParse error \"%s\"",s);
|
||
goto error;
|
||
}
|
||
... | ... | |
return 0;
|
||
error:
|
||
SCLogError(SC_PORT_PARSE_INSERT_STRING_ERR,"DetectPortParseInsertString error");
|
||
SCLogError(SC_ERR_PORT_PARSE_INSERT_STRING_ERR,"DetectPortParseInsertString error");
|
||
if (ad != NULL)
|
||
DetectPortCleanupList(ad);
|
||
if (ad_any != NULL)
|
||
... | ... | |
range = 1;
|
||
if (range == 1 && s[u] == '!') {
|
||
SCLogError(SC_NEGATED_VALUE_IN_PORT_RANGE,"Can't have a negated value in a range.");
|
||
SCLogError(SC_ERR_NEGATED_VALUE_IN_PORT_RANGE,"Can't have a negated value in a range.");
|
||
return -1;
|
||
} else if (!o_set && s[u] == '!') {
|
||
SCLogDebug("negation encountered");
|
||
... | ... | |
/** check if the full port space is negated */
|
||
if (DetectPortIsCompletePortSpace(*nhead) == 1) {
|
||
SCLogError(SC_COMPLETE_PORT_SPACE_NEGATED,"Complete port space is negated");
|
||
SCLogError(SC_ERR_COMPLETE_PORT_SPACE_NEGATED,"Complete port space is negated");
|
||
goto error;
|
||
}
|
||
... | ... | |
}
|
||
if (*head == NULL) {
|
||
SCLogError(SC_NO_PORTS_LEFT_AFTER_MERGE,"no ports left after merging ports with negated ports");
|
||
SCLogError(SC_ERR_NO_PORTS_LEFT_AFTER_MERGE,"no ports left after merging ports with negated ports");
|
||
goto error;
|
||
}
|
||
src/detect-fast-pattern.c | ||
---|---|---|
char *null_str)
|
||
{
|
||
if (null_str != NULL && strcmp(null_str, "") != 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "DetectFastPatternSetup: fast_pattern "
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "DetectFastPatternSetup: fast_pattern "
|
||
"shouldn't be supplied with a value");
|
||
return -1;
|
||
}
|
src/detect-http-cookie.c | ||
---|---|---|
SigMatch *sm = NULL;
|
||
if (str != NULL && strcmp(str, "") != 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "http_cookie shouldn't be supplied with"
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "http_cookie shouldn't be supplied with"
|
||
" an argument");
|
||
return -1;
|
||
}
|
src/detect-http-method.c | ||
---|---|---|
bstr *method;
|
||
if ((str != NULL) && (strcmp(str, "") != 0)) {
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"http_method does not take an argument");
|
||
SCReturnInt(-1);
|
||
}
|
src/detect-icmp-id.c | ||
---|---|---|
ret = pcre_exec(parse_regex, parse_regex_study, icmpidstr, strlen(icmpidstr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 1 || ret > 4) {
|
||
SCLogError(SC_PCRE_MATCH_FAILED, "Parse error %s", icmpidstr);
|
||
SCLogError(SC_ERR_PCRE_MATCH_FAILED, "Parse error %s", icmpidstr);
|
||
goto error;
|
||
}
|
||
... | ... | |
for (i = 1; i < ret; i++) {
|
||
res = pcre_get_substring((char *)icmpidstr, ov, MAX_SUBSTRINGS, i, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
substr[i-1] = (char *)str_ptr;
|
||
... | ... | |
if (strlen(substr[0]) != 0) {
|
||
if (substr[2] == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Missing close quote in input");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing close quote in input");
|
||
goto error;
|
||
}
|
||
} else {
|
||
if (substr[2] != NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Missing open quote in input");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing open quote in input");
|
||
goto error;
|
||
}
|
||
}
|
src/detect-icmp-seq.c | ||
---|---|---|
parse_regex = pcre_compile(PARSE_REGEX, opts, &eb, &eo, NULL);
|
||
if (parse_regex == NULL) {
|
||
SCLogError(SC_PCRE_COMPILE_FAILED,"pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED,"pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
goto error;
|
||
}
|
||
parse_regex_study = pcre_study(parse_regex, 0, &eb);
|
||
if (eb != NULL) {
|
||
SCLogError(SC_PCRE_STUDY_FAILED,"pcre study failed: %s", eb);
|
||
SCLogError(SC_ERR_PCRE_STUDY_FAILED,"pcre study failed: %s", eb);
|
||
goto error;
|
||
}
|
||
return;
|
||
... | ... | |
ret = pcre_exec(parse_regex, parse_regex_study, icmpseqstr, strlen(icmpseqstr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 1 || ret > 4) {
|
||
SCLogError(SC_PCRE_MATCH_FAILED,"Parse error %s", icmpseqstr);
|
||
SCLogError(SC_ERR_PCRE_MATCH_FAILED,"Parse error %s", icmpseqstr);
|
||
goto error;
|
||
}
|
||
for (i = 1; i < ret; i++) {
|
||
res = pcre_get_substring((char *)icmpseqstr, ov, MAX_SUBSTRINGS, i, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED,"pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
substr[i-1] = (char *)str_ptr;
|
src/detect-icode.c | ||
---|---|---|
parse_regex = pcre_compile(PARSE_REGEX, opts, &eb, &eo, NULL);
|
||
if(parse_regex == NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
goto error;
|
||
}
|
||
parse_regex_study = pcre_study(parse_regex, 0, &eb);
|
||
if(eb != NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED, "pcre study failed: %s", eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED, "pcre study failed: %s", eb);
|
||
goto error;
|
||
}
|
||
return;
|
||
... | ... | |
ret = pcre_exec(parse_regex, parse_regex_study, icodestr, strlen(icodestr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 1 || ret > 4) {
|
||
SCLogError(SC_PCRE_MATCH_FAILED, "DetectICodeParse: parse error");
|
||
SCLogError(SC_ERR_PCRE_MATCH_FAILED, "DetectICodeParse: parse error");
|
||
goto error;
|
||
}
|
||
... | ... | |
for (i = 1; i < ret; i++) {
|
||
res = pcre_get_substring((char *)icodestr, ov, MAX_SUBSTRINGS, i, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "DetectICodeParse: pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "DetectICodeParse: pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
args[i-1] = (char *)str_ptr;
|
src/detect-itype.c | ||
---|---|---|
parse_regex = pcre_compile(PARSE_REGEX, opts, &eb, &eo, NULL);
|
||
if(parse_regex == NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", PARSE_REGEX, eo, eb);
|
||
goto error;
|
||
}
|
||
parse_regex_study = pcre_study(parse_regex, 0, &eb);
|
||
if(eb != NULL)
|
||
{
|
||
SCLogError(SC_PCRE_COMPILE_FAILED, "pcre study failed: %s", eb);
|
||
SCLogError(SC_ERR_PCRE_COMPILE_FAILED, "pcre study failed: %s", eb);
|
||
goto error;
|
||
}
|
||
return;
|
||
... | ... | |
ret = pcre_exec(parse_regex, parse_regex_study, itypestr, strlen(itypestr), 0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 1 || ret > 4) {
|
||
SCLogError(SC_PCRE_MATCH_FAILED, "DetectITypeParse: parse error");
|
||
SCLogError(SC_ERR_PCRE_MATCH_FAILED, "DetectITypeParse: parse error");
|
||
goto error;
|
||
}
|
||
... | ... | |
for (i = 1; i < ret; i++) {
|
||
res = pcre_get_substring((char *)itypestr, ov, MAX_SUBSTRINGS, i, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "DetectITypeParse: pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "DetectITypeParse: pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
args[i-1] = (char *)str_ptr;
|
src/detect-offset.c | ||
---|---|---|
DetectContentData *cd = (DetectContentData *)pm->ctx;
|
||
if (cd == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "invalid argument");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid argument");
|
||
if (dubbed) free(str);
|
||
return -1;
|
||
}
|
src/detect-parse.c | ||
---|---|---|
/* Call option parsing */
|
||
st = SigTableGet((char *)arr[0]);
|
||
if (st == NULL) {
|
||
SCLogError(SC_RULE_KEYWORD_UNKNOWN, "unknown rule keyword '%s'.", (char *)arr[0]);
|
||
SCLogError(SC_ERR_RULE_KEYWORD_UNKNOWN, "unknown rule keyword '%s'.", (char *)arr[0]);
|
||
goto error;
|
||
}
|
||
src/detect-rpc.c | ||
---|---|---|
switch (i) {
|
||
case 0:
|
||
if (ByteExtractStringUint32(&rd->program, 10, strlen(args[i]), args[i]) <= 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid size specified for the rpc program:\"%s\"", args[i]);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc program:\"%s\"", args[i]);
|
||
goto error;
|
||
}
|
||
rd->flags |= DETECT_RPC_CHECK_PROGRAM;
|
||
... | ... | |
case 1:
|
||
if (args[i][0] != '*') {
|
||
if (ByteExtractStringUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid size specified for the rpc version:\"%s\"", args[i]);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc version:\"%s\"", args[i]);
|
||
goto error;
|
||
}
|
||
rd->flags |= DETECT_RPC_CHECK_VERSION;
|
||
... | ... | |
case 2:
|
||
if (args[i][0] != '*') {
|
||
if (ByteExtractStringUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
|
||
goto error;
|
||
}
|
||
rd->flags |= DETECT_RPC_CHECK_PROCEDURE;
|
src/detect-urilen.c | ||
---|---|---|
ret = pcre_exec(parse_regex, parse_regex_study, urilenstr, strlen(urilenstr),
|
||
0, 0, ov, MAX_SUBSTRINGS);
|
||
if (ret < 3 || ret > 5) {
|
||
SCLogError(SC_PCRE_PARSE_FAILED, "parse error, ret %" PRId32 "", ret);
|
||
SCLogError(SC_ERR_PCRE_PARSE_FAILED, "parse error, ret %" PRId32 "", ret);
|
||
goto error;
|
||
}
|
||
const char *str_ptr;
|
||
res = pcre_get_substring((char *)urilenstr, ov, MAX_SUBSTRINGS, 1, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
arg1 = (char *) str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)urilenstr, ov, MAX_SUBSTRINGS, 2, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
arg2 = (char *) str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)urilenstr, ov, MAX_SUBSTRINGS, 3, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
arg3 = (char *) str_ptr;
|
||
... | ... | |
res = pcre_get_substring((char *)urilenstr, ov, MAX_SUBSTRINGS, 4, &str_ptr);
|
||
if (res < 0) {
|
||
SCLogError(SC_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
SCLogError(SC_ERR_PCRE_GET_SUBSTRING_FAILED, "pcre_get_substring failed");
|
||
goto error;
|
||
}
|
||
arg4 = (char *) str_ptr;
|
||
... | ... | |
if (strcmp("<>", arg3) == 0) {
|
||
if (strlen(arg1) != 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"Range specified but mode also set");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Range specified but mode also set");
|
||
goto error;
|
||
}
|
||
urilend->mode = DETECT_URILEN_RA;
|
||
... | ... | |
/** set the first urilen value */
|
||
if(ByteExtractStringUint16(&urilend->urilen1,10,strlen(arg2),arg2) <= 0){
|
||
SCLogError(SC_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg2);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg2);
|
||
goto error;
|
||
}
|
||
/** set the second urilen value if specified */
|
||
if (strlen(arg4) > 0) {
|
||
if (urilend->mode != DETECT_URILEN_RA) {
|
||
SCLogError(SC_INVALID_ARGUMENT,"Multiple urilen values specified"
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Multiple urilen values specified"
|
||
" but mode is not range");
|
||
goto error;
|
||
}
|
||
if(ByteExtractStringUint16(&urilend->urilen2,10,strlen(arg4),arg4) <= 0)
|
||
{
|
||
SCLogError(SC_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg4);
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg4);
|
||
goto error;
|
||
}
|
||
if (urilend->urilen2 <= urilend->urilen1){
|
||
SCLogError(SC_INVALID_ARGUMENT,"urilen2:%"PRIu16" <= urilen:"
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,"urilen2:%"PRIu16" <= urilen:"
|
||
"%"PRIu16"",urilend->urilen2,urilend->urilen1);
|
||
goto error;
|
||
}
|
src/detect.c | ||
---|---|---|
int lineno = 0, multiline = 0;
|
||
if (sig_file == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "ERROR opening rule file null.");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "ERROR opening rule file null.");
|
||
return -1;
|
||
}
|
||
src/reputation.c | ||
---|---|---|
{
|
||
Reputation *rep = NULL;
|
||
if (orig == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid arguments");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
|
||
return NULL;
|
||
}
|
||
... | ... | |
struct in_addr *ipv4_addr = (struct in_addr *) ipv4addr;
|
||
if (ipv4_addr == NULL || rep_data == NULL || rep_ctx == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid arguments");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
|
||
return NULL;
|
||
}
|
||
/* If the reputation tree is not initialized yet */
|
||
if (rep_ctx->reputationIPV4_tree == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
return NULL;
|
||
}
|
||
... | ... | |
} else {
|
||
if (netmask_value < 0 || netmask_value > 31) {
|
||
SCLogError(SC_INVALID_IP_NETBLOCK, "Invalid IPV4 Netblock");
|
||
SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV4 Netblock");
|
||
return NULL;
|
||
}
|
||
... | ... | |
struct in_addr *ipv6_addr = (struct in_addr *) ipv6addr;
|
||
if (ipv6_addr == NULL || rep_data == NULL || rep_ctx == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid arguments");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
|
||
return NULL;
|
||
}
|
||
/* If the reputation tree is not initialized yet */
|
||
if (rep_ctx->reputationIPV6_tree == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
return NULL;
|
||
}
|
||
... | ... | |
} else {
|
||
if (netmask_value < 0 || netmask_value > 127) {
|
||
SCLogError(SC_INVALID_IP_NETBLOCK, "Invalid IPV6 Netblock");
|
||
SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV6 Netblock");
|
||
return NULL;
|
||
}
|
||
... | ... | |
Reputation *actual_rep;
|
||
if (ipv4_addr == NULL || rtx == NULL || rep_ctx == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid arguments");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
|
||
return NULL;
|
||
}
|
||
/* If the reputation tree is not initialized yet */
|
||
if (rep_ctx->reputationIPV4_tree == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
return NULL;
|
||
}
|
||
... | ... | |
Reputation *actual_rep;
|
||
if (ipv6_addr == NULL || rtx == NULL || rep_ctx == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Invalid arguments");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
|
||
return NULL;
|
||
}
|
||
/* If the reputation tree is not initialized yet */
|
||
if (rep_ctx->reputationIPV6_tree == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT, "Reputation trees not initialized");
|
||
return NULL;
|
||
}
|
||
src/runmodes.c | ||
---|---|---|
OutputModule *module = OutputGetModuleByConfName(output->val);
|
||
if (module == NULL) {
|
||
SCLogWarning(SC_INVALID_ARGUMENT,
|
||
SCLogWarning(SC_ERR_INVALID_ARGUMENT,
|
||
"No output module named %s, ignoring", output->val);
|
||
continue;
|
||
}
|
||
... | ... | |
output_config = ConfNodeLookupChild(output, module->conf_name);
|
||
if (output_config == NULL) {
|
||
/* Shouldn't happen. */
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"Failed to lookup configuration child node: fast");
|
||
exit(1);
|
||
}
|
||
... | ... | |
}
|
||
tm_module = TmModuleGetByName(module->name);
|
||
if (tm_module == NULL) {
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"TmModuleGetByName for %s failed", module->name);
|
||
exit(EXIT_FAILURE);
|
||
}
|
src/source-nfq.c | ||
---|---|---|
/* Will not be able to copy data ! Set length to 0
|
||
* to trigger an error in packet decoding.
|
||
* This is unlikely to happen */
|
||
SCLogWarning(SC_INVALID_ARGUMENTS, "NFQ sent too big packet");
|
||
SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "NFQ sent too big packet");
|
||
p->pktlen = 0;
|
||
} else {
|
||
memcpy(p->pkt, pktdata, ret);
|
||
... | ... | |
SCLogDebug("opening library handle");
|
||
nfq_t->h = nfq_open();
|
||
if (!nfq_t->h) {
|
||
SCLogError(SC_NFQ_OPEN, "nfq_open() failed");
|
||
SCLogError(SC_ERR_NFQ_OPEN, "nfq_open() failed");
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
... | ... | |
* run. Ignoring the error seems to have no bad effects. */
|
||
SCLogDebug("unbinding existing nf_queue handler for AF_INET (if any)");
|
||
if (nfq_unbind_pf(nfq_t->h, AF_INET) < 0) {
|
||
SCLogWarning(SC_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
|
||
SCLogWarning(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
|
||
}
|
||
if (nfq_unbind_pf(nfq_t->h, AF_INET6) < 0) {
|
||
SCLogWarning(SC_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
|
||
SCLogWarning(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
|
||
}
|
||
nfq_g.unbind = 1;
|
||
SCLogDebug("binding nfnetlink_queue as nf_queue handler for AF_INET and AF_INET6");
|
||
if (nfq_bind_pf(nfq_t->h, AF_INET) < 0) {
|
||
SCLogError(SC_NFQ_BIND, "nfq_bind_pf() for AF_INET failed");
|
||
SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET failed");
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
if (nfq_bind_pf(nfq_t->h, AF_INET6) < 0) {
|
||
SCLogError(SC_NFQ_BIND, "nfq_bind_pf() for AF_INET6 failed");
|
||
SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET6 failed");
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
}
|
||
... | ... | |
nfq_t->qh = nfq_create_queue(nfq_t->h, nfq_t->queue_num, &NFQCallBack, (void *)nfq_t);
|
||
if (nfq_t->qh == NULL)
|
||
{
|
||
SCLogError(SC_NFQ_CREATE_QUEUE, "nfq_create_queue failed");
|
||
SCLogError(SC_ERR_NFQ_CREATE_QUEUE, "nfq_create_queue failed");
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
... | ... | |
/* 05DC = 1500 */
|
||
//if (nfq_set_mode(nfq_t->qh, NFQNL_COPY_PACKET, 0x05DC) < 0) {
|
||
if (nfq_set_mode(nfq_t->qh, NFQNL_COPY_PACKET, 0xFFFF) < 0) {
|
||
SCLogError(SC_NFQ_SET_MODE, "can't set packet_copy mode");
|
||
SCLogError(SC_ERR_NFQ_SET_MODE, "can't set packet_copy mode");
|
||
return TM_ECODE_FAILED;
|
||
}
|
||
... | ... | |
/* non-fatal if it fails */
|
||
if (nfq_set_queue_maxlen(nfq_t->qh, queue_maxlen) < 0) {
|
||
SCLogWarning(SC_NFQ_MAXLEN, "can't set queue maxlen: your kernel probably "
|
||
SCLogWarning(SC_ERR_NFQ_MAXLEN, "can't set queue maxlen: your kernel probably "
|
||
"doesn't support setting the queue length");
|
||
}
|
||
}
|
||
... | ... | |
tv.tv_usec = 0;
|
||
if(setsockopt(nfq_t->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
|
||
SCLogWarning(SC_NFQ_SETSOCKOPT, "can't set socket timeout: %s", strerror(errno));
|
||
SCLogWarning(SC_ERR_NFQ_SETSOCKOPT, "can't set socket timeout: %s", strerror(errno));
|
||
}
|
||
SCLogDebug("nfq_t->h %p, nfq_t->nh %p, nfq_t->qh %p, nfq_t->fd %" PRId32 "",
|
||
... | ... | |
int r = NFQInitThread(ntv,receive_queue_num, NFQ_DFT_QUEUE_LEN);
|
||
if (r < 0) {
|
||
SCLogError(SC_NFQ_THREAD_INIT, "nfq thread failed to initialize");
|
||
SCLogError(SC_ERR_NFQ_THREAD_INIT, "nfq thread failed to initialize");
|
||
SCMutexUnlock(&nfq_init_lock);
|
||
exit(EXIT_FAILURE);
|
||
... | ... | |
#endif /* COUNTERS */
|
||
}
|
||
} else if(rv == 0) {
|
||
SCLogWarning(SC_NFQ_RECV, "recv got returncode 0");
|
||
SCLogWarning(SC_ERR_NFQ_RECV, "recv got returncode 0");
|
||
} else {
|
||
#ifdef DBG_PERF
|
||
if (rv > t->dbg_maxreadsize)
|
||
... | ... | |
SCMutexUnlock(&t->mutex_qh);
|
||
if (ret != 0) {
|
||
SCLogWarning(SC_NFQ_HANDLE_PKT, "nfq_handle_packet error %" PRId32 "", ret);
|
||
SCLogWarning(SC_ERR_NFQ_HANDLE_PKT, "nfq_handle_packet error %" PRId32 "", ret);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
SCMutexUnlock(&t->mutex_qh);
|
||
if (ret < 0) {
|
||
SCLogWarning(SC_NFQ_SET_VERDICT, "nfq_set_verdict of %p failed %" PRId32 "", p, ret);
|
||
SCLogWarning(SC_ERR_NFQ_SET_VERDICT, "nfq_set_verdict of %p failed %" PRId32 "", p, ret);
|
||
}
|
||
}
|
||
src/suricata.c | ||
---|---|---|
/* Wait till all the threads have been initialized */
|
||
if (TmThreadWaitOnThreadInit() == TM_ECODE_FAILED) {
|
||
SCLogError(SC_INITIALIZATION_ERROR, "Engine initialization failed, "
|
||
SCLogError(SC_ERR_INITIALIZATION_ERROR, "Engine initialization failed, "
|
||
"aborting...");
|
||
exit(EXIT_FAILURE);
|
||
}
|
src/tm-threads.c | ||
---|---|---|
inline int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag) {
|
||
int r;
|
||
if (SCSpinLock(&tv->flags_spinlock) != 0) {
|
||
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
SCLogError(SC_ERR_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
return 0;
|
||
}
|
||
... | ... | |
inline void TmThreadsSetFlag(ThreadVars *tv, uint8_t flag) {
|
||
if (SCSpinLock(&tv->flags_spinlock) != 0) {
|
||
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
SCLogError(SC_ERR_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
return;
|
||
}
|
||
... | ... | |
inline void TmThreadsUnsetFlag(ThreadVars *tv, uint8_t flag) {
|
||
if (SCSpinLock(&tv->flags_spinlock) != 0) {
|
||
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
SCLogError(SC_ERR_SPINLOCK_ERROR,"spin lock errno=%d",errno);
|
||
return;
|
||
}
|
||
src/util-byte.c | ||
---|---|---|
*res = strtoull(ptr, &endptr, base);
|
||
if (errno == ERANGE) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
|
||
return -1;
|
||
} else if (endptr == str) {
|
||
SCLogError(SC_INVALID_NUMERIC_VALUE, "Invalid numeric value");
|
||
SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
|
||
return -1;
|
||
/* If there is no numeric value in the given string then strtoull(), makes
|
||
endptr equals to ptr and return 0 as result */
|
||
... | ... | |
*res = (uint32_t)i64;
|
||
if ((uint64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")", (uint64_t)(*res), i64);
|
||
return -1;
|
||
}
|
||
... | ... | |
*res = (uint16_t)i64;
|
||
if ((uint64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")", (uint64_t)(*res), i64);
|
||
return -1;
|
||
}
|
||
... | ... | |
*res = (uint8_t)i64;
|
||
if ((uint64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")", (uint64_t)(*res), i64);
|
||
return -1;
|
||
}
|
||
... | ... | |
*res = strtoll(ptr, &endptr, base);
|
||
if (errno == ERANGE) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
|
||
return -1;
|
||
} else if (endptr == str) {
|
||
SCLogError(SC_INVALID_NUMERIC_VALUE, "Invalid numeric value");
|
||
SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
|
||
return -1;
|
||
}
|
||
/* This will interfere with some rules that do not know the length
|
||
... | ... | |
*res = (int32_t)i64;
|
||
if ((int64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")\n", (int64_t)(*res), i64);
|
||
return -1;
|
||
}
|
||
... | ... | |
*res = (int16_t)i64;
|
||
if ((int64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")\n", (int64_t)(*res), i64);
|
||
return -1;
|
||
}
|
||
... | ... | |
*res = (int8_t)i64;
|
||
if ((int64_t)(*res) != i64) {
|
||
SCLogError(SC_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
|
||
"(%" PRIx64 " != %" PRIx64 ")\n", (int64_t)(*res), i64);
|
||
return -1;
|
||
}
|
src/util-daemon.c | ||
---|---|---|
if (daemon) {
|
||
switch (mode) {
|
||
case MODE_PCAP_FILE:
|
||
SCLogError(SC_INVALID_RUNMODE, "ERROR: pcap offline mode cannot run as daemon");
|
||
SCLogError(SC_ERR_INVALID_RUNMODE, "ERROR: pcap offline mode cannot run as daemon");
|
||
return 0;
|
||
case MODE_UNITTEST:
|
||
SCLogError(SC_INVALID_RUNMODE, "ERROR: unittests cannot run as daemon");
|
||
SCLogError(SC_ERR_INVALID_RUNMODE, "ERROR: unittests cannot run as daemon");
|
||
return 0;
|
||
default:
|
||
SCLogDebug("Allowed mode");
|
src/util-debug.c | ||
---|---|---|
printf("Logging module not initialized. Call SCLogInitLogModule(), "
|
||
"before using the logging API\n");
|
||
#endif
|
||
return SC_LOG_MODULE_NOT_INIT;
|
||
return SC_ERR_LOG_MODULE_NOT_INIT;
|
||
}
|
||
if (sc_log_fg_filters_present == 1) {
|
||
if (SCLogMatchFGFilterWL(file, function, line) != 1)
|
||
return SC_LOG_FG_FILTER_MATCH_FAILED;
|
||
return SC_ERR_LOG_FG_FILTER_MATCH_FAILED;
|
||
if (SCLogMatchFGFilterBL(file, function, line) != 1)
|
||
return SC_LOG_FG_FILTER_MATCH_FAILED;
|
||
return SC_ERR_LOG_FG_FILTER_MATCH_FAILED;
|
||
}
|
||
if (sc_log_fd_filters_present == 1 && SCLogMatchFDFilter(function) != 1)
|
||
return SC_LOG_FG_FILTER_MATCH_FAILED;
|
||
return SC_ERR_LOG_FG_FILTER_MATCH_FAILED;
|
||
while ( (temp_fmt = index(temp_fmt, SC_LOG_FMT_PREFIX)) ) {
|
||
if ((temp - *msg) > SC_LOG_MAX_LOG_MSG_LEN) {
|
||
... | ... | |
return SC_OK;
|
||
error:
|
||
return SC_SPRINTF_ERROR;
|
||
return SC_ERR_SPRINTF_ERROR;
|
||
}
|
||
/**
|
||
... | ... | |
continue;
|
||
}
|
||
if (SCMapEnumNameToValue(interface, sc_log_op_iface_map) < 0) {
|
||
SCLogError(SC_INVALID_ARGUMENT,
|
||
SCLogError(SC_ERR_INVALID_ARGUMENT,
|
||
"Invalid logging interface: %s", interface);
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
... | ... | |
facility = ConfNodeLookupChildValue(output, "facility");
|
||
}
|
||
else {
|
||
SCLogWarning(SC_UNIMPLEMENTED,
|
||
SCLogWarning(SC_ERR_UNIMPLEMENTED,
|
||
"Ignoring unknown logging interface: %s", interface);
|
||
}
|
||
}
|
src/util-error.c | ||
---|---|---|
switch (err) {
|
||
CASE_CODE (SC_OK);
|
||
CASE_CODE (SC_ERR_MEM_ALLOC);
|
||
CASE_CODE (SC_PCRE_MATCH_FAILED);
|
||
CASE_CODE (SC_PCRE_GET_SUBSTRING_FAILED);
|
||
CASE_CODE (SC_PCRE_COMPILE_FAILED);
|
||
CASE_CODE (SC_PCRE_STUDY_FAILED);
|
||
CASE_CODE (SC_PCRE_PARSE_FAILED);
|
||
CASE_CODE (SC_LOG_MODULE_NOT_INIT);
|
||
CASE_CODE (SC_LOG_FG_FILTER_MATCH_FAILED);
|
||
CASE_CODE (SC_ERR_PCRE_MATCH_FAILED);
|
||
CASE_CODE (SC_ERR_PCRE_GET_SUBSTRING_FAILED);
|
||
CASE_CODE (SC_ERR_PCRE_COMPILE_FAILED);
|
||
CASE_CODE (SC_ERR_PCRE_STUDY_FAILED);
|
||
CASE_CODE (SC_ERR_PCRE_PARSE_FAILED);
|
||
CASE_CODE (SC_ERR_LOG_MODULE_NOT_INIT);
|
||
CASE_CODE (SC_ERR_LOG_FG_FILTER_MATCH_FAILED);
|
||
CASE_CODE (SC_ERR_INVALID_SIGNATURE);
|
||
CASE_CODE (SC_ERR_OPENING_FILE);
|
||
CASE_CODE (SC_ERR_OPENING_RULE_FILE);
|
||
CASE_CODE (SC_ERR_NO_RULES);
|
||
CASE_CODE (SC_ERR_NO_RULES_LOADED);
|
||
CASE_CODE (SC_COUNTER_EXCEEDED);
|
||
CASE_CODE (SC_INVALID_CHECKSUM);
|
||
CASE_CODE (SC_SPRINTF_ERROR);
|
||
CASE_CODE (SC_INVALID_ARGUMENT);
|
||
CASE_CODE (SC_SPINLOCK_ERROR);
|
||
CASE_CODE (SC_INVALID_ENUM_MAP);
|
||
CASE_CODE (SC_INVALID_IP_NETBLOCK);
|
||
CASE_CODE (SC_INVALID_IPV4_ADDR);
|
||
CASE_CODE (SC_INVALID_IPV6_ADDR);
|
||
CASE_CODE (SC_INVALID_RUNMODE);
|
||
CASE_CODE (SC_COMPLETE_PORT_SPACE_NEGATED);
|
||
CASE_CODE (SC_NO_PORTS_LEFT_AFTER_MERGE);
|
||
CASE_CODE (SC_NEGATED_VALUE_IN_PORT_RANGE);
|
||
CASE_CODE (SC_PORT_PARSE_INSERT_STRING_ERR);
|
||
CASE_CODE (SC_UNREACHABLE_CODE_REACHED);
|
||
CASE_CODE (SC_INVALID_NUMERIC_VALUE);
|
||
CASE_CODE (SC_NUMERIC_VALUE_ERANGE);
|
||
CASE_CODE (SC_INVALID_NUM_BYTES);
|
||
CASE_CODE (SC_ERR_COUNTER_EXCEEDED);
|
||
CASE_CODE (SC_ERR_INVALID_CHECKSUM);
|
||
CASE_CODE (SC_ERR_SPRINTF_ERROR);
|
||
CASE_CODE (SC_ERR_INVALID_ARGUMENT);
|
||
CASE_CODE (SC_ERR_SPINLOCK_ERROR);
|
||
CASE_CODE (SC_ERR_INVALID_ENUM_MAP);
|
||
CASE_CODE (SC_ERR_INVALID_IP_NETBLOCK);
|
||
CASE_CODE (SC_ERR_INVALID_IPV4_ADDR);
|
||
CASE_CODE (SC_ERR_INVALID_IPV6_ADDR);
|
||
CASE_CODE (SC_ERR_INVALID_RUNMODE);
|
||
CASE_CODE (SC_ERR_COMPLETE_PORT_SPACE_NEGATED);
|
||
CASE_CODE (SC_ERR_NO_PORTS_LEFT_AFTER_MERGE);
|
||
CASE_CODE (SC_ERR_NEGATED_VALUE_IN_PORT_RANGE);
|
||
CASE_CODE (SC_ERR_PORT_PARSE_INSERT_STRING_ERR);
|
||
CASE_CODE (SC_ERR_UNREACHABLE_CODE_REACHED);
|
||
CASE_CODE (SC_ERR_INVALID_NUMERIC_VALUE);
|
||
CASE_CODE (SC_ERR_NUMERIC_VALUE_ERANGE);
|
||
CASE_CODE (SC_ERR_INVALID_NUM_BYTES);
|
||
CASE_CODE (SC_ERR_ARG_LEN_LONG);
|
||
CASE_CODE (SC_ALPARSER_ERR);
|
||
CASE_CODE (SC_ERR_ALPARSER_ERR);
|
||
CASE_CODE (SC_ERR_POOL_EMPTY);
|
||
CASE_CODE (SC_ERR_REASSEMBLY_FAILED);
|
||
CASE_CODE (SC_ERR_POOL_INIT_FAILED);
|
||
CASE_CODE (SC_UNIMPLEMENTED);
|
||
CASE_CODE (SC_ERR_UNIMPLEMENTED);
|
||
CASE_CODE (SC_ERR_FAST_LOG_GENERIC_ERROR);
|
||
CASE_CODE (SC_ERR_DEBUG_LOG_GENERIC_ERROR);
|
||
CASE_CODE (SC_ERR_UNIFIED_LOG_GENERIC_ERROR);
|
||
... | ... | |
CASE_CODE (SC_ERR_FOPEN);
|
||
CASE_CODE (SC_ERR_THRESHOLD_HASH_ADD);
|
||
CASE_CODE (SC_ERR_UNDEFINED_VAR);
|
||
CASE_CODE (SC_RULE_KEYWORD_UNKNOWN);
|
||
CASE_CODE (SC_ERR_RULE_KEYWORD_UNKNOWN);
|
||
CASE_CODE (SC_ERR_FLAGS_MODIFIER);
|
||
CASE_CODE (SC_ERR_DISTANCE_MISSING_CONTENT);
|
||
CASE_CODE (SC_ERR_WITHIN_MISSING_CONTENT);
|
src/util-error.h | ||
---|---|---|
typedef enum {
|
||
SC_OK,
|
||
SC_ERR_MEM_ALLOC,
|
||
SC_PCRE_MATCH_FAILED,
|
||
SC_PCRE_GET_SUBSTRING_FAILED,
|
||
SC_PCRE_COMPILE_FAILED,
|
||
SC_PCRE_STUDY_FAILED,
|
||
SC_PCRE_PARSE_FAILED,
|
||
SC_LOG_MODULE_NOT_INIT,
|
||
SC_LOG_FG_FILTER_MATCH_FAILED,
|
||
SC_COUNTER_EXCEEDED,
|
||
SC_INVALID_CHECKSUM,
|
||
SC_SPRINTF_ERROR,
|
||
SC_INVALID_ARGUMENT,
|
||
SC_SPINLOCK_ERROR,
|
||
SC_INVALID_ENUM_MAP,
|
||
SC_INVALID_IP_NETBLOCK,
|
||
SC_INVALID_IPV4_ADDR,
|
||
SC_INVALID_IPV6_ADDR,
|
||
SC_INVALID_RUNMODE,
|
||
SC_ERR_PCRE_MATCH_FAILED,
|
||
SC_ERR_PCRE_GET_SUBSTRING_FAILED,
|
||
SC_ERR_PCRE_COMPILE_FAILED,
|
||
SC_ERR_PCRE_STUDY_FAILED,
|
||
SC_ERR_PCRE_PARSE_FAILED,
|