From 39f5c7f56ab7c70616304ad55be4a118edee2530 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 21 Oct 2022 12:24:58 +0200 Subject: [PATCH] error: use SC_EINVAL for invalid input --- src/app-layer-htp-range.c | 4 +-- src/app-layer-htp.c | 30 +++++++++------- src/counters.c | 7 ++-- src/datasets.c | 8 ++--- src/decode.c | 6 ++-- src/defrag-config.c | 6 ++-- src/detect-asn1.c | 3 +- src/detect-bytejump.c | 28 +++++++++------ src/detect-bytetest.c | 17 +++++---- src/detect-classtype.c | 4 +-- src/detect-datarep.c | 4 +-- src/detect-dataset.c | 4 +-- src/detect-detection-filter.c | 2 +- src/detect-engine-content-inspection.c | 2 +- src/detect-engine-mpm.c | 4 +-- src/detect-engine-threshold.c | 5 ++- src/detect-engine.c | 19 +++++----- src/detect-flow.c | 2 +- src/detect-fragbits.c | 2 +- src/detect-id.c | 9 ++--- src/detect-ipproto.c | 5 ++- src/detect-isdataat.c | 2 +- src/detect-lua.c | 18 ++++++---- src/detect-mqtt-connect-flags.c | 10 +++--- src/detect-mqtt-flags.c | 4 +-- src/detect-noalert.c | 2 +- src/detect-nocase.c | 2 +- src/detect-prefilter.c | 2 +- src/detect-rawbytes.c | 2 +- src/detect-replace.c | 3 +- src/detect-rpc.c | 2 +- src/detect-ssl-version.c | 8 ++--- src/detect-tag.c | 22 +++++++++--- src/detect-target.c | 2 +- src/detect-tls-version.c | 2 +- src/detect-xbits.c | 8 +++-- src/flow.c | 4 +-- src/output-json-flow.c | 4 +-- src/reputation.c | 6 ++-- src/runmode-af-packet.c | 33 ++++++++---------- src/runmode-dpdk.c | 48 ++++++++++++-------------- src/runmode-napatech.c | 2 +- src/runmode-netmap.c | 14 ++++---- src/runmode-pcap.c | 6 ++-- src/runmode-pfring.c | 30 ++++++++++------ src/source-af-packet.c | 39 +++++++++------------ src/source-erf-dag.c | 3 +- src/source-netmap.c | 2 +- src/source-nflog.c | 6 ++-- src/source-nfq.c | 2 +- src/source-pcap.c | 2 +- src/source-pfring.c | 10 +++--- src/tests/stream-tcp.c | 2 +- src/unix-manager.c | 2 +- src/util-cpu.c | 6 ++-- src/util-device.c | 2 +- src/util-ebpf.c | 42 ++++++++-------------- src/util-error.c | 3 +- src/util-error.h | 1 - src/util-hash.c | 4 +-- src/util-host-info.c | 7 ++-- src/util-ja3.c | 2 +- src/util-log-redis.c | 9 ++--- src/util-napatech.c | 36 ++++++++++++------- src/util-print.c | 2 +- src/util-runmodes.c | 8 ++--- src/util-spm.c | 4 +-- src/util-storage.c | 7 ++-- src/util-threshold-config.c | 21 +++++------ 69 files changed, 324 insertions(+), 305 deletions(-) diff --git a/src/app-layer-htp-range.c b/src/app-layer-htp-range.c index 4826142e16..5067fb5fd5 100644 --- a/src/app-layer-htp-range.c +++ b/src/app-layer-htp-range.c @@ -155,7 +155,7 @@ void HttpRangeContainersInit(void) uint32_t timeout = HTTP_RANGE_DEFAULT_TIMEOUT; if (ConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) { if (ParseSizeStringU64(str, &memcap) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "memcap value cannot be deduced: %s," " resetting to default", str); @@ -165,7 +165,7 @@ void HttpRangeContainersInit(void) if (ConfGet("app-layer.protocols.http.byterange.timeout", &str) == 1) { size_t slen = strlen(str); if (slen > UINT16_MAX || StringParseUint32(&timeout, 10, (uint16_t)slen, str) <= 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "timeout value cannot be deduced: %s," " resetting to default", str); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index c3dec401d7..c0cab84906 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2587,16 +2587,19 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, SCLogDebug("LIBHTP adding ipv6 server %s at %s: %p", s->name, pval->val, cfg_prec->cfg); if (SCRadixAddKeyIPV6String(pval->val, tree, cfg_prec) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, "LIBHTP failed to " - "add ipv6 server %s, ignoring", pval->val); + SCLogWarning(SC_EINVAL, + "LIBHTP failed to " + "add ipv6 server %s, ignoring", + pval->val); } } else { SCLogDebug("LIBHTP adding ipv4 server %s at %s: %p", s->name, pval->val, cfg_prec->cfg); if (SCRadixAddKeyIPV4String(pval->val, tree, cfg_prec) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, "LIBHTP failed " - "to add ipv4 server %s, ignoring", - pval->val); + SCLogWarning(SC_EINVAL, + "LIBHTP failed " + "to add ipv4 server %s, ignoring", + pval->val); } } /* else - if (strchr(pval->val, ':') != NULL) */ } /* TAILQ_FOREACH(pval, &p->head, next) */ @@ -2611,8 +2614,10 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, SCLogDebug("LIBHTP default: %s=%s (%d)", p->name, p->val, personality); if (htp_config_set_server_personality(cfg_prec->cfg, personality) == HTP_ERROR){ - SCLogWarning(SC_ERR_INVALID_VALUE, "LIBHTP Failed adding " - "personality \"%s\", ignoring", p->val); + SCLogWarning(SC_EINVAL, + "LIBHTP Failed adding " + "personality \"%s\", ignoring", + p->val); } else { SCLogDebug("LIBHTP personality set to %s", HTPLookupPersonalityString(personality)); @@ -2843,11 +2848,12 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, uint32_t range; if (StringParseU32RangeCheck(&range, 10, 0, (const char *)p->val, 0, 100) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for randomize" - "-inspection-range setting from conf file - \"%s\"." - " It should be a valid integer less than or equal to 100." - " Killing engine", - p->val); + SCLogError(SC_EINVAL, + "Invalid value for randomize" + "-inspection-range setting from conf file - \"%s\"." + " It should be a valid integer less than or equal to 100." + " Killing engine", + p->val); exit(EXIT_FAILURE); } cfg_prec->randomize_range = range; diff --git a/src/counters.c b/src/counters.c index 33ebbe43c7..b568d335e7 100644 --- a/src/counters.c +++ b/src/counters.c @@ -271,9 +271,10 @@ static void StatsInitCtxPreOutput(void) const char *interval = ConfNodeLookupChildValue(stats, "interval"); if (interval != NULL) if (StringParseUint32(&stats_tts, 10, 0, interval) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "interval: \"%s\". Resetting to %d.", interval, - STATS_MGMTT_TTS); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "interval: \"%s\". Resetting to %d.", + interval, STATS_MGMTT_TTS); stats_tts = STATS_MGMTT_TTS; } diff --git a/src/datasets.c b/src/datasets.c index e61456b198..69f364fc8f 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -855,7 +855,7 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) const char *str = NULL; if (ConfGet("datasets.defaults.memcap", &str) == 1) { if (ParseSizeStringU64(str, memcap) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "memcap value cannot be deduced: %s," " resetting to default", str); @@ -864,7 +864,7 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) } if (ConfGet("datasets.defaults.hashsize", &str) == 1) { if (ParseSizeStringU32(str, hashsize) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "hashsize value cannot be deduced: %s," " resetting to default", str); @@ -925,7 +925,7 @@ int DatasetsInit(void) ConfNode *set_memcap = ConfNodeLookupChild(iter, "memcap"); if (set_memcap) { if (ParseSizeStringU64(set_memcap->val, &memcap) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "memcap value cannot be" " deduced: %s, resetting to default", set_memcap->val); @@ -935,7 +935,7 @@ int DatasetsInit(void) ConfNode *set_hashsize = ConfNodeLookupChild(iter, "hashsize"); if (set_hashsize) { if (ParseSizeStringU32(set_hashsize->val, &hashsize) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "hashsize value cannot be" " deduced: %s, resetting to default", set_hashsize->val); diff --git a/src/decode.c b/src/decode.c index fec718c64c..dbe7f2d9ef 100644 --- a/src/decode.c +++ b/src/decode.c @@ -850,7 +850,7 @@ void DecodeGlobalConfig(void) intmax_t value = 0; if (ConfGetInt("decoder.max-layers", &value) == 1) { if (value < 0 || value > UINT8_MAX) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for decoder.max-layers"); + SCLogWarning(SC_EINVAL, "Invalid value for decoder.max-layers"); } else { decoder_max_layers = (uint8_t)value; } @@ -863,8 +863,8 @@ void PacketAlertGetMaxConfig(void) intmax_t max = 0; if (ConfGetInt("packet-alert-max", &max) == 1) { if (max <= 0 || max > UINT8_MAX) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Invalid value for packet-alert-max, default value set instead"); + SCLogWarning( + SC_EINVAL, "Invalid value for packet-alert-max, default value set instead"); } else { packet_alert_max = (uint16_t)max; } diff --git a/src/defrag-config.c b/src/defrag-config.c index beafe962f6..9660b2e98e 100644 --- a/src/defrag-config.c +++ b/src/defrag-config.c @@ -52,14 +52,12 @@ static void DefragPolicyAddHostInfo(char *host_ip_range, uint64_t timeout) if (strchr(host_ip_range, ':') != NULL) { SCLogDebug("adding ipv6 host %s", host_ip_range); if (SCRadixAddKeyIPV6String(host_ip_range, defrag_tree, (void *)user_data) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "failed to add ipv6 host %s", host_ip_range); + SCLogWarning(SC_EINVAL, "failed to add ipv6 host %s", host_ip_range); } } else { SCLogDebug("adding ipv4 host %s", host_ip_range); if (SCRadixAddKeyIPV4String(host_ip_range, defrag_tree, (void *)user_data) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "failed to add ipv4 host %s", host_ip_range); + SCLogWarning(SC_EINVAL, "failed to add ipv4 host %s", host_ip_range); } } } diff --git a/src/detect-asn1.c b/src/detect-asn1.c index b21445e37a..eea1810d11 100644 --- a/src/detect-asn1.c +++ b/src/detect-asn1.c @@ -104,8 +104,7 @@ static DetectAsn1Data *DetectAsn1Parse(const char *asn1str) DetectAsn1Data *ad = rs_detect_asn1_parse(asn1str); if (ad == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed asn1 argument: %s", - asn1str); + SCLogError(SC_EINVAL, "Malformed asn1 argument: %s", asn1str); } return ad; diff --git a/src/detect-bytejump.c b/src/detect-bytejump.c index 7a842f38b7..e78fa674ad 100644 --- a/src/detect-bytejump.c +++ b/src/detect-bytejump.c @@ -399,7 +399,7 @@ static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const ch /* Number of bytes */ if (StringParseUint32(&nbytes, 10, (uint16_t)strlen(args[0]), args[0]) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed number of bytes: %s", optstr); + SCLogError(SC_EINVAL, "Malformed number of bytes: %s", optstr); goto error; } @@ -416,7 +416,7 @@ static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const ch goto error; } else { if (StringParseInt32(&data->offset, 0, (uint16_t)strlen(args[1]), args[1]) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed offset: %s", optstr); + SCLogError(SC_EINVAL, "Malformed offset: %s", optstr); goto error; } } @@ -450,19 +450,19 @@ static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const ch } else if (strncasecmp("multiplier ", args[i], 11) == 0) { if (StringParseUint32( &data->multiplier, 10, (uint16_t)strlen(args[i]) - 11, args[i] + 11) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed multiplier: %s", optstr); + SCLogError(SC_EINVAL, "Malformed multiplier: %s", optstr); goto error; } } else if (strncasecmp("post_offset ", args[i], 12) == 0) { if (StringParseInt32(&data->post_offset, 10, (uint16_t)strlen(args[i]) - 12, args[i] + 12) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed post_offset: %s", optstr); + SCLogError(SC_EINVAL, "Malformed post_offset: %s", optstr); goto error; } } else if (strcasecmp("dce", args[i]) == 0) { data->flags |= DETECT_BYTEJUMP_DCE; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Unknown option: \"%s\"", args[i]); + SCLogError(SC_EINVAL, "Unknown option: \"%s\"", args[i]); goto error; } } @@ -482,19 +482,25 @@ static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const ch * "01777777777777777777777" = 0xffffffffffffffff */ if (nbytes > 23) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot test more than 23 bytes " - "with \"string\": %s", optstr); + SCLogError(SC_EINVAL, + "Cannot test more than 23 bytes " + "with \"string\": %s", + optstr); goto error; } } else { if (nbytes > 8) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot test more than 8 bytes " - "without \"string\": %s\n", optstr); + SCLogError(SC_EINVAL, + "Cannot test more than 8 bytes " + "without \"string\": %s\n", + optstr); goto error; } if (data->base != DETECT_BYTEJUMP_BASE_UNSET) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot use a base " - "without \"string\": %s", optstr); + SCLogError(SC_EINVAL, + "Cannot use a base " + "without \"string\": %s", + optstr); goto error; } } diff --git a/src/detect-bytetest.c b/src/detect-bytetest.c index d231b6edb4..dcdf2734a5 100644 --- a/src/detect-bytetest.c +++ b/src/detect-bytetest.c @@ -327,7 +327,7 @@ static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, /* Number of bytes */ if (StringParseUint32(&nbytes, 10, 0, args[0]) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed number of bytes: %s", str_ptr); + SCLogError(SC_EINVAL, "Malformed number of bytes: %s", str_ptr); goto error; } @@ -388,7 +388,7 @@ static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, goto error; } else { if (ByteExtractStringUint64(&data->value, 0, 0, test_value) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed value: %s", test_value); + SCLogError(SC_EINVAL, "Malformed value: %s", test_value); goto error; } } @@ -417,7 +417,7 @@ static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, goto error; } else { if (StringParseInt32(&data->offset, 0, 0, data_offset) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed offset: %s", data_offset); + SCLogError(SC_EINVAL, "Malformed offset: %s", data_offset); goto error; } } @@ -467,18 +467,16 @@ static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, * "01777777777777777777777" = 0xffffffffffffffff */ if (nbytes > 23) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot test more than 23 bytes with \"string\": %s", - optstr); + SCLogError(SC_EINVAL, "Cannot test more than 23 bytes with \"string\": %s", optstr); goto error; } } else { if (nbytes > 8) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot test more than 8 bytes without \"string\": %s", - optstr); + SCLogError(SC_EINVAL, "Cannot test more than 8 bytes without \"string\": %s", optstr); goto error; } if (data->base != DETECT_BYTETEST_BASE_UNSET) { - SCLogError(SC_ERR_INVALID_VALUE, "Cannot use a base without \"string\": %s", optstr); + SCLogError(SC_EINVAL, "Cannot use a base without \"string\": %s", optstr); goto error; } } @@ -488,7 +486,8 @@ static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, if (bitmask_index != -1 && data->flags & DETECT_BYTETEST_BITMASK) { if (ByteExtractStringUint32(&data->bitmask, 0, 0, args[bitmask_index]+strlen("bitmask")) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed bitmask value: %s", args[bitmask_index]+strlen("bitmask")); + SCLogError(SC_EINVAL, "Malformed bitmask value: %s", + args[bitmask_index] + strlen("bitmask")); goto error; } /* determine how many trailing 0's are in the bitmask. This will be used diff --git a/src/detect-classtype.c b/src/detect-classtype.c index ae4490c035..002ebc6f51 100644 --- a/src/detect-classtype.c +++ b/src/detect-classtype.c @@ -88,8 +88,8 @@ static int DetectClasstypeParseRawString(const char *rawstr, char *out, size_t o } if (strlen(e) >= CLASSTYPE_NAME_MAX_LEN) { - SCLogError(SC_ERR_INVALID_VALUE, "classtype '%s' is too big: max %d", - rawstr, CLASSTYPE_NAME_MAX_LEN - 1); + SCLogError( + SC_EINVAL, "classtype '%s' is too big: max %d", rawstr, CLASSTYPE_NAME_MAX_LEN - 1); return -1; } (void)strlcpy(out, e, outsize); diff --git a/src/detect-datarep.c b/src/detect-datarep.c index fac0a131da..cfc3ba3505 100644 --- a/src/detect-datarep.c +++ b/src/detect-datarep.c @@ -176,7 +176,7 @@ static int DetectDatarepParse(const char *str, char *cmd, int cmd_len, char *nam } if (strcmp(key, "memcap") == 0) { if (ParseSizeStringU64(val, memcap) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "invalid value for memcap: %s," " resetting to default", val); @@ -185,7 +185,7 @@ static int DetectDatarepParse(const char *str, char *cmd, int cmd_len, char *nam } if (strcmp(key, "hashsize") == 0) { if (ParseSizeStringU32(val, hashsize) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "invalid value for hashsize: %s," " resetting to default", val); diff --git a/src/detect-dataset.c b/src/detect-dataset.c index ad6a580589..2384a07585 100644 --- a/src/detect-dataset.c +++ b/src/detect-dataset.c @@ -198,7 +198,7 @@ static int DetectDatasetParse(const char *str, char *cmd, int cmd_len, char *nam } if (strcmp(key, "memcap") == 0) { if (ParseSizeStringU64(val, memcap) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "invalid value for memcap: %s," " resetting to default", val); @@ -207,7 +207,7 @@ static int DetectDatasetParse(const char *str, char *cmd, int cmd_len, char *nam } if (strcmp(key, "hashsize") == 0) { if (ParseSizeStringU32(val, hashsize) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "invalid value for hashsize: %s," " resetting to default", val); diff --git a/src/detect-detection-filter.c b/src/detect-detection-filter.c index 1212c6952f..b7b15b53e5 100644 --- a/src/detect-detection-filter.c +++ b/src/detect-detection-filter.c @@ -180,7 +180,7 @@ static DetectThresholdData *DetectDetectionFilterParse(const char *rawstr) } if (df->count == 0 || df->seconds == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "found an invalid value"); + SCLogError(SC_EINVAL, "found an invalid value"); goto error; } diff --git a/src/detect-engine-content-inspection.c b/src/detect-engine-content-inspection.c index 529f5155d1..ae8b5cf421 100644 --- a/src/detect-engine-content-inspection.c +++ b/src/detect-engine-content-inspection.c @@ -328,7 +328,7 @@ uint8_t DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThrea * cast to non-const as replace writes to it. */ det_ctx->replist = DetectReplaceAddToList(det_ctx->replist, (uint8_t *)found, cd); } else { - SCLogWarning(SC_ERR_INVALID_VALUE, "Can't modify payload without packet"); + SCLogWarning(SC_EINVAL, "Can't modify payload without packet"); } } diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index e7b2b45e56..c6d33a29e0 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -870,8 +870,8 @@ uint8_t PatternMatchDefaultMatcher(void) #ifndef BUILD_HYPERSCAN if ((strcmp(mpm_algo, "hs") == 0)) { - FatalError(SC_ERR_INVALID_VALUE, "Hyperscan (hs) support for mpm-algo is " - "not compiled into Suricata."); + FatalError(SC_EINVAL, "Hyperscan (hs) support for mpm-algo is " + "not compiled into Suricata."); } #endif } diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index 3190550fcf..1645013fc3 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -281,8 +281,7 @@ static int ThresholdHandlePacketSuppress(Packet *p, break; case TRACK_RULE: default: - SCLogError(SC_ERR_INVALID_VALUE, - "track mode %d is not supported", td->track); + SCLogError(SC_EINVAL, "track mode %d is not supported", td->track); break; } if (m == NULL) @@ -529,7 +528,7 @@ static int ThresholdHandlePacket(Packet *p, DetectThresholdEntry *lookup_tsh, } /* case TYPE_SUPPRESS: is not handled here */ default: - SCLogError(SC_ERR_INVALID_VALUE, "type %d is not supported", td->type); + SCLogError(SC_EINVAL, "type %d is not supported", td->type); } return ret; } diff --git a/src/detect-engine.c b/src/detect-engine.c index 3df1d334f6..bdaebda10a 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2722,10 +2722,11 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) if (insp_recursion_limit != NULL) { if (StringParseInt32(&de_ctx->inspection_recursion_limit, 10, 0, (const char *)insp_recursion_limit) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "detect-engine.inspection-recursion-limit: %s " - "resetting to %d", insp_recursion_limit, - DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "detect-engine.inspection-recursion-limit: %s " + "resetting to %d", + insp_recursion_limit, DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT); de_ctx->inspection_recursion_limit = DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT; } @@ -4006,8 +4007,8 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) int vlanbool = 0; if ((ConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "vlan tracking is disabled, " - "can't use multi-detect selector 'vlan'"); + SCLogError(SC_EINVAL, "vlan tracking is disabled, " + "can't use multi-detect selector 'vlan'"); SCMutexUnlock(&master->lock); goto error; } @@ -4024,8 +4025,10 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) } } else { - SCLogError(SC_ERR_INVALID_VALUE, "unknown value %s " - "multi-detect.selector", handler); + SCLogError(SC_EINVAL, + "unknown value %s " + "multi-detect.selector", + handler); SCMutexUnlock(&master->lock); goto error; } diff --git a/src/detect-flow.c b/src/detect-flow.c index 6f9e414276..ae26b05dc0 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -306,7 +306,7 @@ static DetectFlowData *DetectFlowParse (DetectEngineCtx *de_ctx, const char *flo } fd->flags |= DETECT_FLOW_FLAG_ONLY_FRAG; } else { - SCLogError(SC_ERR_INVALID_VALUE, "invalid flow option \"%s\"", args[i]); + SCLogError(SC_EINVAL, "invalid flow option \"%s\"", args[i]); goto error; } diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index 0dbca7a672..2483648495 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -193,7 +193,7 @@ static DetectFragBitsData *DetectFragBitsParse (const char *rawstr) } if (args[1] == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "invalid value"); + SCLogError(SC_EINVAL, "invalid value"); goto error; } diff --git a/src/detect-id.c b/src/detect-id.c index 2f9b54245c..3a086c2bcc 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -129,9 +129,10 @@ static DetectIdData *DetectIdParse (const char *idstr) ret = DetectParsePcreExec(&parse_regex, idstr, 0, 0); if (ret < 1 || ret > 3) { - SCLogError(SC_ERR_INVALID_VALUE, "invalid id option '%s'. The id option " - "value must be in the range %u - %u", - idstr, DETECT_IPID_MIN, DETECT_IPID_MAX); + SCLogError(SC_EINVAL, + "invalid id option '%s'. The id option " + "value must be in the range %u - %u", + idstr, DETECT_IPID_MIN, DETECT_IPID_MAX); return NULL; } @@ -154,7 +155,7 @@ static DetectIdData *DetectIdParse (const char *idstr) /* ok, fill the id data */ if (StringParseUint16(&temp, 10, 0, (const char *)tmp_str) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "invalid id option '%s'", tmp_str); + SCLogError(SC_EINVAL, "invalid id option '%s'", tmp_str); return NULL; } diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index 656f07daee..4b6ca45abf 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -124,15 +124,14 @@ static DetectIPProtoData *DetectIPProtoParse(const char *optstr) if (!isdigit((unsigned char)*(args[1]))) { uint8_t proto; if (!SCGetProtoByName(args[1], &proto)) { - SCLogError(SC_ERR_INVALID_VALUE, "Unknown protocol name: \"%s\"", str_ptr); + SCLogError(SC_EINVAL, "Unknown protocol name: \"%s\"", str_ptr); goto error; } data->proto = proto; } else { if (StringParseUint8(&data->proto, 10, 0, args[1]) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Malformed protocol number: %s", - str_ptr); + SCLogError(SC_EINVAL, "Malformed protocol number: %s", str_ptr); goto error; } } diff --git a/src/detect-isdataat.c b/src/detect-isdataat.c index 9da3216260..faf4c43aa8 100644 --- a/src/detect-isdataat.c +++ b/src/detect-isdataat.c @@ -158,7 +158,7 @@ static DetectIsdataatData *DetectIsdataatParse (DetectEngineCtx *de_ctx, const c } else { if (StringParseUint16(&idad->dataat, 10, strlen(args[0]), args[0]) < 0 ) { - SCLogError(SC_ERR_INVALID_VALUE, "isdataat out of range"); + SCLogError(SC_EINVAL, "isdataat out of range"); SCFree(idad); idad = NULL; goto error; diff --git a/src/detect-lua.c b/src/detect-lua.c index f3b29a53db..8196c546a6 100644 --- a/src/detect-lua.c +++ b/src/detect-lua.c @@ -268,8 +268,10 @@ int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx, if (strcmp(k, "retval") == 0) { int val; if (StringParseInt32(&val, 10, 0, (const char *)v) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value " - "for \"retval\" from LUA return table: '%s'", v); + SCLogError(SC_EINVAL, + "Invalid value " + "for \"retval\" from LUA return table: '%s'", + v); ret = 0; } else if (val == 1) { @@ -423,8 +425,10 @@ static int DetectLuaMatch (DetectEngineThreadCtx *det_ctx, int val; if (StringParseInt32(&val, 10, 0, (const char *)v) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value " - "for \"retval\" from LUA return table: '%s'", v); + SCLogError(SC_EINVAL, + "Invalid value " + "for \"retval\" from LUA return table: '%s'", + v); ret = 0; } else if (val == 1) { @@ -532,8 +536,10 @@ static int DetectLuaAppMatchCommon (DetectEngineThreadCtx *det_ctx, int val; if (StringParseInt32(&val, 10, 0, (const char *)v) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value " - "for \"retval\" from LUA return table: '%s'", v); + SCLogError(SC_EINVAL, + "Invalid value " + "for \"retval\" from LUA return table: '%s'", + v); ret = 0; } else if (val == 1) { diff --git a/src/detect-mqtt-connect-flags.c b/src/detect-mqtt-connect-flags.c index c5ff4261f3..e2119a82aa 100644 --- a/src/detect-mqtt-connect-flags.c +++ b/src/detect-mqtt-connect-flags.c @@ -152,31 +152,31 @@ static DetectMQTTConnectFlagsData *DetectMQTTConnectFlagsParse(const char *rawst } if (strcmp(flagv+offset, "username") == 0) { if (de->username != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->username = fs_to_set; } else if (strcmp(flagv+offset, "password") == 0) { if (de->password != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->password = fs_to_set; } else if (strcmp(flagv+offset, "will") == 0) { if (de->will != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->will = fs_to_set; } else if (strcmp(flagv+offset, "will_retain") == 0) { if (de->will_retain != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->will_retain = fs_to_set; } else if (strcmp(flagv+offset, "clean_session") == 0) { if (de->clean_session != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->clean_session = fs_to_set; diff --git a/src/detect-mqtt-flags.c b/src/detect-mqtt-flags.c index bbde89e9a2..33e470e92a 100644 --- a/src/detect-mqtt-flags.c +++ b/src/detect-mqtt-flags.c @@ -150,13 +150,13 @@ static DetectMQTTFlagsData *DetectMQTTFlagsParse(const char *rawstr) } if (strcmp(flagv+offset, "dup") == 0) { if (de->dup != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->dup = fs_to_set; } else if (strcmp(flagv+offset, "retain") == 0) { if (de->retain != MQTT_DONT_CARE) { - SCLogError(SC_ERR_INVALID_VALUE, "duplicate flag definition: %s", flagv); + SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv); goto error; } de->retain = fs_to_set; diff --git a/src/detect-noalert.c b/src/detect-noalert.c index 0a89163e45..9ca2d29a44 100644 --- a/src/detect-noalert.c +++ b/src/detect-noalert.c @@ -42,7 +42,7 @@ void DetectNoalertRegister (void) static int DetectNoalertSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr) { if (nullstr != NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "nocase has no value"); + SCLogError(SC_EINVAL, "nocase has no value"); return -1; } diff --git a/src/detect-nocase.c b/src/detect-nocase.c index b2d8b834a0..a8d67fb711 100644 --- a/src/detect-nocase.c +++ b/src/detect-nocase.c @@ -62,7 +62,7 @@ static int DetectNocaseSetup (DetectEngineCtx *de_ctx, Signature *s, const char int ret = -1; if (nullstr != NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "nocase has value"); + SCLogError(SC_EINVAL, "nocase has value"); goto end; } diff --git a/src/detect-prefilter.c b/src/detect-prefilter.c index 87e8491e7c..a348022b86 100644 --- a/src/detect-prefilter.c +++ b/src/detect-prefilter.c @@ -57,7 +57,7 @@ static int DetectPrefilterSetup (DetectEngineCtx *de_ctx, Signature *s, const ch SCEnter(); if (nullstr != NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "prefilter has value"); + SCLogError(SC_EINVAL, "prefilter has value"); SCReturnInt(-1); } diff --git a/src/detect-rawbytes.c b/src/detect-rawbytes.c index d478f70724..e28a1f51c8 100644 --- a/src/detect-rawbytes.c +++ b/src/detect-rawbytes.c @@ -55,7 +55,7 @@ static int DetectRawbytesSetup(DetectEngineCtx *de_ctx, Signature *s, const char SCEnter(); if (nullstr != NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "rawbytes has no value"); + SCLogError(SC_EINVAL, "rawbytes has no value"); SCReturnInt(-1); } diff --git a/src/detect-replace.c b/src/detect-replace.c index cb0cf169f8..72d547ea6f 100644 --- a/src/detect-replace.c +++ b/src/detect-replace.c @@ -96,8 +96,7 @@ int DetectReplaceSetup(DetectEngineCtx *de_ctx, Signature *s, const char *replac uint16_t len = 0; if (s->init_data->negated) { - SCLogError(SC_ERR_INVALID_VALUE, "Can't negate replacement string: %s", - replacestr); + SCLogError(SC_EINVAL, "Can't negate replacement string: %s", replacestr); return -1; } diff --git a/src/detect-rpc.c b/src/detect-rpc.c index 5394511027..95ef8f08c8 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -227,7 +227,7 @@ static DetectRpcData *DetectRpcParse (DetectEngineCtx *de_ctx, const char *rpcst break; } } else { - SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",rpcstr); + SCLogError(SC_EINVAL, "invalid rpc option %s", rpcstr); goto error; } } diff --git a/src/detect-ssl-version.c b/src/detect-ssl-version.c index ad81c82374..e91d092393 100644 --- a/src/detect-ssl-version.c +++ b/src/detect-ssl-version.c @@ -215,7 +215,7 @@ static DetectSslVersionData *DetectSslVersionParse(DetectEngineCtx *de_ctx, cons tmp_str++; } if (tmp_str[0] == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid empty value"); + SCLogError(SC_EINVAL, "Invalid empty value"); goto error; } // iterate every version separated by comma @@ -236,7 +236,7 @@ static DetectSslVersionData *DetectSslVersionParse(DetectEngineCtx *de_ctx, cons if (tmp_len == strlen(ssl_version_keywords[i].word) && strncasecmp(ssl_version_keywords[i].word, tmp_str, tmp_len) == 0) { if (ssl->data[ssl_version_keywords[i].index].ver != 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid duplicate value"); + SCLogError(SC_EINVAL, "Invalid duplicate value"); goto error; } ssl->data[ssl_version_keywords[i].index].ver = ssl_version_keywords[i].value; @@ -247,7 +247,7 @@ static DetectSslVersionData *DetectSslVersionParse(DetectEngineCtx *de_ctx, cons } } if (!is_keyword) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid unknown value"); + SCLogError(SC_EINVAL, "Invalid unknown value"); goto error; } @@ -257,7 +257,7 @@ static DetectSslVersionData *DetectSslVersionParse(DetectEngineCtx *de_ctx, cons if (found == 0) { found |= 1 << neg; } else if (found != 1 << neg) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value mixing negative and positive forms"); + SCLogError(SC_EINVAL, "Invalid value mixing negative and positive forms"); goto error; } diff --git a/src/detect-tag.c b/src/detect-tag.c index c9e0a4dbdd..0a3e64d4f8 100644 --- a/src/detect-tag.c +++ b/src/detect-tag.c @@ -178,7 +178,7 @@ static DetectTagData *DetectTagParse(const char *tagstr) } else if (strcasecmp("host", str_ptr) == 0) { td.type = DETECT_TAG_TYPE_HOST; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid argument type. Must be session or host (%s)", tagstr); + SCLogError(SC_EINVAL, "Invalid argument type. Must be session or host (%s)", tagstr); goto error; } pcre2_substring_free((PCRE2_UCHAR *)str_ptr); @@ -200,7 +200,10 @@ static DetectTagData *DetectTagParse(const char *tagstr) /* count */ if (StringParseUint32(&td.count, 10, strlen(str_ptr), str_ptr) <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid argument for count. Must be a value in the range of 0 to %"PRIu32" (%s)", UINT32_MAX, tagstr); + SCLogError(SC_EINVAL, + "Invalid argument for count. Must be a value in the range of 0 to %" PRIu32 + " (%s)", + UINT32_MAX, tagstr); goto error; } @@ -225,7 +228,10 @@ static DetectTagData *DetectTagParse(const char *tagstr) } else if (strcasecmp("bytes", str_ptr) == 0) { td.metric = DETECT_TAG_METRIC_BYTES; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid argument metric. Must be one of \"seconds\", \"packets\" or \"bytes\" (%s)", tagstr); + SCLogError(SC_EINVAL, + "Invalid argument metric. Must be one of \"seconds\", \"packets\" or \"bytes\" " + "(%s)", + tagstr); goto error; } @@ -247,12 +253,18 @@ static DetectTagData *DetectTagParse(const char *tagstr) } else if (strcasecmp("dst", str_ptr) == 0) { td.direction = DETECT_TAG_DIR_DST; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid argument direction. Must be one of \"src\" or \"dst\" (only valid for tag host type, not sessions) (%s)", tagstr); + SCLogError(SC_EINVAL, + "Invalid argument direction. Must be one of \"src\" or \"dst\" (only valid " + "for tag host type, not sessions) (%s)", + tagstr); goto error; } if (td.type != DETECT_TAG_TYPE_HOST) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Argument direction doesn't make sense for type \"session\" (%s [%"PRIu8"])", tagstr, td.type); + SCLogWarning(SC_EINVAL, + "Argument direction doesn't make sense for type \"session\" (%s [%" PRIu8 + "])", + tagstr, td.type); } pcre2_substring_free((PCRE2_UCHAR *)str_ptr); diff --git a/src/detect-target.c b/src/detect-target.c index bd842427d8..10e182de13 100644 --- a/src/detect-target.c +++ b/src/detect-target.c @@ -114,7 +114,7 @@ static int DetectTargetParse(Signature *s, const char *targetstr) } s->flags |= SIG_FLAG_DEST_IS_TARGET; } else { - SCLogError(SC_ERR_INVALID_VALUE, "only 'src_ip' and 'dest_ip' are supported as target value"); + SCLogError(SC_EINVAL, "only 'src_ip' and 'dest_ip' are supported as target value"); return -1; } return 0; diff --git a/src/detect-tls-version.c b/src/detect-tls-version.c index 20dac3ef10..6bc0259f84 100644 --- a/src/detect-tls-version.c +++ b/src/detect-tls-version.c @@ -196,7 +196,7 @@ static DetectTlsVersionData *DetectTlsVersionParse (DetectEngineCtx *de_ctx, con temp = (uint16_t)strtol(tmp_str, NULL, 0); tls->flags |= DETECT_TLS_VERSION_FLAG_RAW; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value"); + SCLogError(SC_EINVAL, "Invalid value"); goto error; } diff --git a/src/detect-xbits.c b/src/detect-xbits.c index 6dc3dd425c..1e21468fef 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -259,12 +259,14 @@ static int DetectXbitParse(DetectEngineCtx *de_ctx, } SCLogDebug("expire_str %s", expire_str); if (StringParseUint32(&expire, 10, 0, (const char *)expire_str) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for " - "expire: \"%s\"", expire_str); + SCLogError(SC_EINVAL, + "Invalid value for " + "expire: \"%s\"", + expire_str); return -1; } if (expire == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "expire must be bigger than 0"); + SCLogError(SC_EINVAL, "expire must be bigger than 0"); return -1; } SCLogDebug("expire %d", expire); diff --git a/src/flow.c b/src/flow.c index 47d3beca64..3375c98057 100644 --- a/src/flow.c +++ b/src/flow.c @@ -564,8 +564,8 @@ void FlowInitConfig(bool quiet) if (val <= 100 && val >= 1) { flow_config.emergency_recovery = (uint8_t)val; } else { - SCLogError(SC_ERR_INVALID_VALUE, "flow.emergency-recovery must be in the range of " - "1 and 100 (as percentage)"); + SCLogError(SC_EINVAL, "flow.emergency-recovery must be in the range of " + "1 and 100 (as percentage)"); flow_config.emergency_recovery = FLOW_DEFAULT_EMERGENCY_RECOVERY; } } else { diff --git a/src/output-json-flow.c b/src/output-json-flow.c index f817bc1fb2..46484a8140 100644 --- a/src/output-json-flow.c +++ b/src/output-json-flow.c @@ -249,9 +249,7 @@ static void EveFlowLogJSON(OutputJsonThreadCtx *aft, JsonBuilder *jb, Flow *f) break; #endif default: - SCLogError(SC_ERR_INVALID_VALUE, - "Invalid flow state: %d, contact developers", - flow_state); + SCLogError(SC_EINVAL, "Invalid flow state: %d, contact developers", flow_state); } } diff --git a/src/reputation.c b/src/reputation.c index e6907c8b15..012d4acf8d 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -100,8 +100,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8 SCLogDebug("adding ipv6 host %s", ip); if (SCRadixAddKeyIPV6String(ip, cidr_ctx->srepIPV6_tree[cat], (void *)user_data) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "failed to add ipv6 host %s", ip); + SCLogWarning(SC_EINVAL, "failed to add ipv6 host %s", ip); } } else { @@ -116,8 +115,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8 SCLogDebug("adding ipv4 host %s", ip); if (SCRadixAddKeyIPV4String(ip, cidr_ctx->srepIPV4_tree[cat], (void *)user_data) == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "failed to add ipv4 host %s", ip); + SCLogWarning(SC_EINVAL, "failed to add ipv4 host %s", ip); } } } diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 2b01edab55..badd786f22 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -198,8 +198,8 @@ static void *ParseAFPConfig(const char *iface) aconf->threads = 0; } else { if (StringParseInt32(&aconf->threads, 10, 0, (const char *)threadsstr) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid number of " - "threads, resetting to default"); + SCLogWarning(SC_EINVAL, "Invalid number of " + "threads, resetting to default"); aconf->threads = 0; } } @@ -283,7 +283,7 @@ static void *ParseAFPConfig(const char *iface) aconf->cluster_id = (uint16_t)(cluster_id_auto++); } else { if (StringParseUint16(&aconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid cluster_id, resetting to 0"); + SCLogWarning(SC_EINVAL, "Invalid cluster_id, resetting to 0"); aconf->cluster_id = 0; } SCLogDebug("Going to use cluster-id %" PRIu16, aconf->cluster_id); @@ -406,7 +406,7 @@ static void *ParseAFPConfig(const char *iface) &aconf->ebpf_lb_fd, &aconf->ebpf_t_config); if (ret != 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Error when loading eBPF lb file"); + SCLogWarning(SC_EINVAL, "Error when loading eBPF lb file"); } } #else @@ -445,8 +445,7 @@ static void *ParseAFPConfig(const char *iface) &aconf->ebpf_filter_fd, &aconf->ebpf_t_config); if (ret != 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Error when loading eBPF filter file"); + SCLogWarning(SC_EINVAL, "Error when loading eBPF filter file"); } #else SCLogError(SC_ERR_UNIMPLEMENTED, "eBPF support is not build-in"); @@ -496,8 +495,7 @@ static void *ParseAFPConfig(const char *iface) aconf->xdp_mode = XDP_FLAGS_HW_MODE; aconf->ebpf_t_config.flags |= EBPF_XDP_HW_MODE; } else { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Invalid xdp-mode value: '%s'", xdp_mode); + SCLogWarning(SC_EINVAL, "Invalid xdp-mode value: '%s'", xdp_mode); } } @@ -523,14 +521,12 @@ static void *ParseAFPConfig(const char *iface) SCLogInfo("Loaded pinned maps from sysfs"); break; case -1: - SCLogWarning(SC_ERR_INVALID_VALUE, - "Error when loading XDP filter file"); + SCLogWarning(SC_EINVAL, "Error when loading XDP filter file"); break; case 0: ret = EBPFSetupXDP(aconf->iface, aconf->xdp_filter_fd, aconf->xdp_mode); if (ret != 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Error when setting up XDP"); + SCLogWarning(SC_EINVAL, "Error when setting up XDP"); } else { /* Try to get the xdp-cpu-redirect key */ const char *cpuset; @@ -539,8 +535,7 @@ static void *ParseAFPConfig(const char *iface) SCLogConfig("Setting up CPU map XDP"); ConfNode *node = ConfGetChildWithDefault(if_root, if_default, "xdp-cpu-redirect"); if (node == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, - "Previously found node has disappeared"); + SCLogError(SC_EINVAL, "Previously found node has disappeared"); } else { EBPFBuildCPUSet(node, aconf->iface); } @@ -570,7 +565,7 @@ static void *ParseAFPConfig(const char *iface) if ((ConfGetChildValueIntWithDefault(if_root, if_default, "block-size", &value)) == 1) { if (value % getpagesize()) { - SCLogError(SC_ERR_INVALID_VALUE, "Block-size must be a multiple of pagesize."); + SCLogError(SC_EINVAL, "Block-size must be a multiple of pagesize."); } else { aconf->block_size = value; } @@ -712,7 +707,7 @@ int AFPRunModeIsIPS() for (ldev = 0; ldev < nlive; ldev++) { const char *live_dev = LiveGetDeviceName(ldev); if (live_dev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } const char *copymodestr = NULL; @@ -720,7 +715,7 @@ int AFPRunModeIsIPS() if (if_root == NULL) { if (if_default == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = if_default; @@ -744,7 +739,7 @@ int AFPRunModeIsIPS() for (ldev = 0; ldev < nlive; ldev++) { const char *live_dev = LiveGetDeviceName(ldev); if (live_dev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = ConfNodeLookupKeyValue(af_packet_node, "interface", live_dev); @@ -752,7 +747,7 @@ int AFPRunModeIsIPS() if (if_root == NULL) { if (if_default == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = if_default; diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index 5118d2bd59..798e63bfd5 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -333,7 +333,7 @@ static void ConfigSetIface(DPDKIfaceConfig *iconf, const char *entry_str) int retval; if (entry_str == NULL || entry_str[0] == '\0') - FatalError(SC_ERR_INVALID_VALUE, "Interface name in DPDK config is NULL or empty"); + FatalError(SC_EINVAL, "Interface name in DPDK config is NULL or empty"); retval = rte_eth_dev_get_port_by_name(entry_str, &iconf->port_id); if (retval < 0) @@ -354,8 +354,7 @@ static int ConfigSetThreads(DPDKIfaceConfig *iconf, const char *entry_str) } if (entry_str == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Number of threads for interface \"%s\" not specified", - iconf->iface); + SCLogError(SC_EINVAL, "Number of threads for interface \"%s\" not specified", iconf->iface); SCReturnInt(-EINVAL); } @@ -366,15 +365,14 @@ static int ConfigSetThreads(DPDKIfaceConfig *iconf, const char *entry_str) } if (StringParseInt32(&iconf->threads, 10, 0, entry_str) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, + SCLogError(SC_EINVAL, "Threads entry for interface %s contain non-numerical characters - \"%s\"", iconf->iface, entry_str); SCReturnInt(-EINVAL); } if (iconf->threads < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Interface %s has a negative number of threads", - iconf->iface); + SCLogError(SC_EINVAL, "Interface %s has a negative number of threads", iconf->iface); SCReturnInt(-ERANGE); } @@ -386,8 +384,8 @@ static int ConfigSetRxQueues(DPDKIfaceConfig *iconf, uint16_t nb_queues) SCEnter(); iconf->nb_rx_queues = nb_queues; if (iconf->nb_rx_queues < 1) { - SCLogError(SC_ERR_INVALID_VALUE, - "Interface %s requires to have positive number of RX queues", iconf->iface); + SCLogError(SC_EINVAL, "Interface %s requires to have positive number of RX queues", + iconf->iface); SCReturnInt(-ERANGE); } @@ -399,8 +397,8 @@ static int ConfigSetTxQueues(DPDKIfaceConfig *iconf, uint16_t nb_queues) SCEnter(); iconf->nb_tx_queues = nb_queues; if (iconf->nb_tx_queues < 1) { - SCLogError(SC_ERR_INVALID_VALUE, - "Interface %s requires to have positive number of TX queues", iconf->iface); + SCLogError(SC_EINVAL, "Interface %s requires to have positive number of TX queues", + iconf->iface); SCReturnInt(-ERANGE); } @@ -411,8 +409,8 @@ static int ConfigSetMempoolSize(DPDKIfaceConfig *iconf, intmax_t entry_int) { SCEnter(); if (entry_int <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Interface %s requires to have positive memory pool size", - iconf->iface); + SCLogError( + SC_EINVAL, "Interface %s requires to have positive memory pool size", iconf->iface); SCReturnInt(-ERANGE); } @@ -429,8 +427,7 @@ static int ConfigSetMempoolCacheSize(DPDKIfaceConfig *iconf, const char *entry_s // RTE_MEMPOOL_CACHE_MAX_SIZE (by default 512) and "mempool-size / 1.5" // and at the same time "mempool-size modulo cache_size == 0". if (iconf->mempool_size == 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Cannot calculate mempool cache size of a mempool with size %d", + SCLogError(SC_EINVAL, "Cannot calculate mempool cache size of a mempool with size %d", iconf->mempool_size); SCReturnInt(-EINVAL); } @@ -441,7 +438,7 @@ static int ConfigSetMempoolCacheSize(DPDKIfaceConfig *iconf, const char *entry_s } if (StringParseUint32(&iconf->mempool_cache_size, 10, 0, entry_str) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, + SCLogError(SC_EINVAL, "Mempool cache size entry for interface %s contain non-numerical " "characters - \"%s\"", iconf->iface, entry_str); @@ -449,7 +446,7 @@ static int ConfigSetMempoolCacheSize(DPDKIfaceConfig *iconf, const char *entry_s } if (iconf->mempool_cache_size <= 0 || iconf->mempool_cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE) { - SCLogError(SC_ERR_INVALID_VALUE, + SCLogError(SC_EINVAL, "Interface %s requires to have mempool cache size set to a positive number smaller " "than %" PRIu32, iconf->iface, RTE_MEMPOOL_CACHE_MAX_SIZE); @@ -463,8 +460,8 @@ static int ConfigSetRxDescriptors(DPDKIfaceConfig *iconf, intmax_t entry_int) { SCEnter(); if (entry_int <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Interface %s requires to have positive number of RX descriptors", iconf->iface); + SCLogError(SC_EINVAL, "Interface %s requires to have positive number of RX descriptors", + iconf->iface); SCReturnInt(-ERANGE); } @@ -476,8 +473,8 @@ static int ConfigSetTxDescriptors(DPDKIfaceConfig *iconf, intmax_t entry_int) { SCEnter(); if (entry_int <= 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Interface %s requires to have positive number of TX descriptors", iconf->iface); + SCLogError(SC_EINVAL, "Interface %s requires to have positive number of TX descriptors", + iconf->iface); SCReturnInt(-ERANGE); } @@ -494,7 +491,7 @@ static int ConfigSetRSSHashFunctions(DPDKIfaceConfig *iconf, const char *entry_s } if (StringParseUint64(&iconf->rss_hf, 0, 0, entry_str) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, + SCLogError(SC_EINVAL, "RSS hash functions entry for interface %s contain non-numerical " "characters - \"%s\"", iconf->iface, entry_str); @@ -508,7 +505,7 @@ static int ConfigSetMtu(DPDKIfaceConfig *iconf, intmax_t entry_int) { SCEnter(); if (entry_int < RTE_ETHER_MIN_MTU || entry_int > RTE_ETHER_MAX_JUMBO_FRAME_LEN) { - SCLogError(SC_ERR_INVALID_VALUE, + SCLogError(SC_EINVAL, "Interface %s requires to have size of MTU between %" PRIu32 " and %" PRIu32, iconf->iface, RTE_ETHER_MIN_MTU, RTE_ETHER_MAX_JUMBO_FRAME_LEN); SCReturnInt(-ERANGE); @@ -580,15 +577,14 @@ static int ConfigSetCopyMode(DPDKIfaceConfig *iconf, const char *entry_str) { SCEnter(); if (entry_str == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Interface %s has no copy mode specified, changing to %s ", iconf->iface, - DPDK_CONFIG_DEFAULT_COPY_MODE); + SCLogWarning(SC_EINVAL, "Interface %s has no copy mode specified, changing to %s ", + iconf->iface, DPDK_CONFIG_DEFAULT_COPY_MODE); entry_str = DPDK_CONFIG_DEFAULT_COPY_MODE; } if (strcmp(entry_str, "none") != 0 && strcmp(entry_str, "tap") != 0 && strcmp(entry_str, "ips") != 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, + SCLogWarning(SC_EINVAL, "Copy mode \"%s\" is not one of the possible values (none|tap|ips) for interface " "%s. Changing to %s", entry_str, iconf->iface, DPDK_CONFIG_DEFAULT_COPY_MODE); diff --git a/src/runmode-napatech.c b/src/runmode-napatech.c index 76726926d5..8350014ff5 100644 --- a/src/runmode-napatech.c +++ b/src/runmode-napatech.c @@ -195,7 +195,7 @@ static void *NapatechConfigParser(const char *device) /* device+2 is a pointer to the beginning of the stream id after the constant nt portion */ if (StringParseUint16(&conf->stream_id, 10, 0, device + 2) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for stream_id: %s", device + 2); + SCLogError(SC_EINVAL, "Invalid value for stream_id: %s", device + 2); SCFree(conf); return NULL; } diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index a4f22b7c40..c198b81ed2 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -151,8 +151,10 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, ns->threads_auto = true; } else { if (StringParseUint16(&ns->threads, 10, 0, threadsstr) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid config value for " - "threads: %s, resetting to 0", threadsstr); + SCLogWarning(SC_EINVAL, + "Invalid config value for " + "threads: %s, resetting to 0", + threadsstr); ns->threads = 0; } } @@ -347,7 +349,7 @@ int NetmapRunModeIsIPS() for (ldev = 0; ldev < nlive; ldev++) { const char *live_dev = LiveGetDeviceName(ldev); if (live_dev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } const char *copymodestr = NULL; @@ -355,7 +357,7 @@ int NetmapRunModeIsIPS() if (if_root == NULL) { if (if_default == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = if_default; @@ -379,7 +381,7 @@ int NetmapRunModeIsIPS() for (ldev = 0; ldev < nlive; ldev++) { const char *live_dev = LiveGetDeviceName(ldev); if (live_dev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev); @@ -387,7 +389,7 @@ int NetmapRunModeIsIPS() if (if_root == NULL) { if (if_default == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); + SCLogError(SC_EINVAL, "Problem with config file"); return 0; } if_root = if_default; diff --git a/src/runmode-pcap.c b/src/runmode-pcap.c index 942277e36e..a81b5649a6 100644 --- a/src/runmode-pcap.c +++ b/src/runmode-pcap.c @@ -142,8 +142,10 @@ static void *ParsePcapConfig(const char *iface) } else { if (threadsstr != NULL) { if (StringParseInt32(&aconf->threads, 10, 0, (const char *)threadsstr) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pcap.threads: %s, resetting to 1", threadsstr); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pcap.threads: %s, resetting to 1", + threadsstr); aconf->threads = 1; } } diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index 58f3322a02..774f7bcb24 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -124,8 +124,10 @@ static void *OldParsePfringConfig(const char *iface) } else { if (threadsstr != NULL) { if (StringParseInt32(&pfconf->threads, 10, 0, threadsstr) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pfring.threads: '%s'. Resetting to 1.", threadsstr); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pfring.threads: '%s'. Resetting to 1.", + threadsstr); pfconf->threads = 1; } } @@ -146,8 +148,10 @@ static void *OldParsePfringConfig(const char *iface) SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config"); } else { if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pfring.cluster_id: '%s'. Resetting to 1.", tmpclusterid); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pfring.cluster_id: '%s'. Resetting to 1.", + tmpclusterid); pfconf->cluster_id = 1; } pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER; @@ -265,8 +269,10 @@ static void *ParsePfringConfig(const char *iface) } else { uint16_t threads = 0; if (StringParseUint16(&threads, 10, 0, (const char *)threadsstr) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pfring.threads: '%s'. Resetting to 1.", threadsstr); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pfring.threads: '%s'. Resetting to 1.", + threadsstr); pfconf->threads = 1; } else { pfconf->threads = threads; @@ -283,8 +289,10 @@ static void *ParsePfringConfig(const char *iface) /* command line value has precedence */ if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) { if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pfring.cluster-id: '%s'. Resetting to 1.", tmpclusterid); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pfring.cluster-id: '%s'. Resetting to 1.", + tmpclusterid); pfconf->cluster_id = 1; } pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER; @@ -303,8 +311,10 @@ static void *ParsePfringConfig(const char *iface) "Could not get cluster-id from config"); } else { if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for " - "pfring.cluster-id: '%s'. Resetting to 1.", tmpclusterid); + SCLogWarning(SC_EINVAL, + "Invalid value for " + "pfring.cluster-id: '%s'. Resetting to 1.", + tmpclusterid); pfconf->cluster_id = 1; } pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER; diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 901173e823..ad20c8e8c8 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -655,7 +655,7 @@ static void AFPWritePacket(Packet *p, int version) } if (p->ethh == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Should have an Ethernet header"); + SCLogWarning(SC_EINVAL, "Should have an Ethernet header"); return; } @@ -1553,8 +1553,7 @@ frame size: TPACKET_ALIGN(snaplen + TPACKET_ALIGN(TPACKET_ALIGN(tp_hdrlen) + siz if (snaplen == 0) { snaplen = GetIfaceMaxPacketSize(ptv->iface); if (snaplen <= 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Unable to get MTU, setting snaplen to sane default of 1514"); + SCLogWarning(SC_EINVAL, "Unable to get MTU, setting snaplen to sane default of 1514"); snaplen = 1514; } } @@ -1563,7 +1562,7 @@ frame size: TPACKET_ALIGN(snaplen + TPACKET_ALIGN(TPACKET_ALIGN(tp_hdrlen) + siz ptv->req.v2.tp_block_size = getpagesize() << order; int frames_per_block = ptv->req.v2.tp_block_size / ptv->req.v2.tp_frame_size; if (frames_per_block == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Frame size bigger than block size"); + SCLogError(SC_EINVAL, "Frame size bigger than block size"); return -1; } ptv->req.v2.tp_frame_nr = ptv->ring_size; @@ -1588,8 +1587,7 @@ static int AFPComputeRingParamsV3(AFPThreadVars *ptv) if (snaplen == 0) { snaplen = GetIfaceMaxPacketSize(ptv->iface); if (snaplen <= 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Unable to get MTU, setting snaplen to sane default of 1514"); + SCLogWarning(SC_EINVAL, "Unable to get MTU, setting snaplen to sane default of 1514"); snaplen = 1514; } } @@ -1598,9 +1596,8 @@ static int AFPComputeRingParamsV3(AFPThreadVars *ptv) frames_per_block = ptv->req.v3.tp_block_size / ptv->req.v3.tp_frame_size; if (frames_per_block == 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Block size is too small, it should be at least %d", - ptv->req.v3.tp_frame_size); + SCLogError(SC_EINVAL, "Block size is too small, it should be at least %d", + ptv->req.v3.tp_frame_size); return -1; } ptv->req.v3.tp_block_nr = ptv->ring_size / frames_per_block + 1; @@ -1806,8 +1803,10 @@ int AFPIsFanoutSupported(uint16_t cluster_id) close(fd); if (r < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "fanout not supported by kernel: " - "Kernel too old or cluster-id %d already in use.", cluster_id); + SCLogError(SC_EINVAL, + "fanout not supported by kernel: " + "Kernel too old or cluster-id %d already in use.", + cluster_id); return 0; } return 1; @@ -1822,13 +1821,12 @@ static int SockFanoutSeteBPF(AFPThreadVars *ptv) { int pfd = ptv->ebpf_lb_fd; if (pfd == -1) { - SCLogError(SC_ERR_INVALID_VALUE, - "Fanout file descriptor is invalid"); + SCLogError(SC_EINVAL, "Fanout file descriptor is invalid"); return -1; } if (setsockopt(ptv->socket, SOL_PACKET, PACKET_FANOUT_DATA, &pfd, sizeof(pfd))) { - SCLogError(SC_ERR_INVALID_VALUE, "Error setting ebpf"); + SCLogError(SC_EINVAL, "Error setting ebpf"); return -1; } SCLogInfo("Activated eBPF on socket"); @@ -1840,13 +1838,12 @@ static int SetEbpfFilter(AFPThreadVars *ptv) { int pfd = ptv->ebpf_filter_fd; if (pfd == -1) { - SCLogError(SC_ERR_INVALID_VALUE, - "Filter file descriptor is invalid"); + SCLogError(SC_EINVAL, "Filter file descriptor is invalid"); return -1; } if (setsockopt(ptv->socket, SOL_SOCKET, SO_ATTACH_BPF, &pfd, sizeof(pfd))) { - SCLogError(SC_ERR_INVALID_VALUE, "Error setting ebpf: %s", strerror(errno)); + SCLogError(SC_EINVAL, "Error setting ebpf: %s", strerror(errno)); return -1; } SCLogInfo("Activated eBPF filter on socket"); @@ -2506,7 +2503,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data) ptv->livedev = LiveGetDevice(ptv->iface); if (ptv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device"); + SCLogError(SC_EINVAL, "Unable to find Live device"); SCFree(ptv); SCReturnInt(TM_ECODE_FAILED); } @@ -2546,16 +2543,14 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data) ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4"); if (ptv->v4_map_fd == -1) { if (g_flowv4_ok == false) { - SCLogError(SC_ERR_INVALID_VALUE, "Can't find eBPF map fd for '%s'", - "flow_table_v4"); + SCLogError(SC_EINVAL, "Can't find eBPF map fd for '%s'", "flow_table_v4"); g_flowv4_ok = true; } } ptv->v6_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v6"); if (ptv->v6_map_fd == -1) { if (g_flowv6_ok) { - SCLogError(SC_ERR_INVALID_VALUE, "Can't find eBPF map fd for '%s'", - "flow_table_v6"); + SCLogError(SC_EINVAL, "Can't find eBPF map fd for '%s'", "flow_table_v6"); g_flowv6_ok = false; } } diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index 424ecb3cee..531b986aa2 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -209,8 +209,7 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data) ewtn->livedev = LiveGetDevice(initdata); if (ewtn->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to get %s live device", - (char *)initdata); + SCLogError(SC_EINVAL, "Unable to get %s live device", (char *)initdata); SCFree(ewtn); SCReturnInt(TM_ECODE_FAILED); } diff --git a/src/source-netmap.c b/src/source-netmap.c index 61de69fe36..c1d97666ef 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -518,7 +518,7 @@ static TmEcode ReceiveNetmapThreadInit(ThreadVars *tv, const void *initdata, voi ntv->livedev = LiveGetDevice(aconf->iface_name); if (ntv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device"); + SCLogError(SC_EINVAL, "Unable to find Live device"); goto error_ntv; } diff --git a/src/source-nflog.c b/src/source-nflog.c index e9d035e145..7064530670 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -286,9 +286,9 @@ TmEcode ReceiveNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data ntv->livedev = LiveGetDevice(nflconfig->numgroup); if (ntv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device"); - SCFree(ntv); - SCReturnInt(TM_ECODE_FAILED); + SCLogError(SC_EINVAL, "Unable to find Live device"); + SCFree(ntv); + SCReturnInt(TM_ECODE_FAILED); } /* set a timeout to the socket so we can check for a signal diff --git a/src/source-nfq.c b/src/source-nfq.c index fcf28cb44a..a9d34813bf 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -845,7 +845,7 @@ int NFQRegisterQueue(const uint16_t number) ntv->livedev = LiveGetDevice(queue); if (ntv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device"); + SCLogError(SC_EINVAL, "Unable to find Live device"); return -1; } diff --git a/src/source-pcap.c b/src/source-pcap.c index 8df56da60c..9f59cde284 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -409,7 +409,7 @@ static TmEcode ReceivePcapThreadInit(ThreadVars *tv, const void *initdata, void ptv->livedev = LiveGetDevice(pcapconfig->iface); if (ptv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "unable to find Live device"); + SCLogError(SC_EINVAL, "unable to find Live device"); SCFree(ptv); SCReturnInt(TM_ECODE_FAILED); } diff --git a/src/source-pfring.c b/src/source-pfring.c index 4b8205f56c..2077811f6d 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -514,7 +514,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat ptv->livedev = LiveGetDevice(pfconf->iface); if (ptv->livedev == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device"); + SCLogError(SC_EINVAL, "Unable to find Live device"); SCFree(ptv); SCReturnInt(TM_ECODE_FAILED); } @@ -536,9 +536,8 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat if (ptv->checksum_mode == CHECKSUM_VALIDATION_RXONLY) { if (strncmp(ptv->interface, "dna", 3) == 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, - "Can't use rxonly checksum-checks on DNA interface," - " resetting to auto"); + SCLogWarning(SC_EINVAL, "Can't use rxonly checksum-checks on DNA interface," + " resetting to auto"); ptv->checksum_mode = CHECKSUM_VALIDATION_AUTO; } else { opflag |= PF_RING_LONG_HEADER; @@ -610,8 +609,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat SCMutexUnlock(&pfring_bpf_set_filter_lock); if (rc < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Failed to compile BPF \"%s\"", - ptv->bpf_filter); + SCLogError(SC_EINVAL, "Failed to compile BPF \"%s\"", ptv->bpf_filter); return TM_ECODE_FAILED; } } diff --git a/src/tests/stream-tcp.c b/src/tests/stream-tcp.c index 8b9d962bd4..f19717fd4c 100644 --- a/src/tests/stream-tcp.c +++ b/src/tests/stream-tcp.c @@ -1065,7 +1065,7 @@ static const char *StreamTcpParseOSPolicy(char *conf_var_name) if (snprintf(conf_var_full_name, strlen(conf_var_type_name) + strlen(conf_var_name) + 2, "%s.%s", conf_var_type_name, conf_var_name) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Error in making the conf full name"); + SCLogError(SC_EINVAL, "Error in making the conf full name"); goto end; } diff --git a/src/unix-manager.c b/src/unix-manager.c index 313de0f968..31e1cbf517 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -272,7 +272,7 @@ static void UnixCommandClose(UnixCommand *this, int fd) } if (found == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "No fd found in client list"); + SCLogError(SC_EINVAL, "No fd found in client list"); return; } diff --git a/src/util-cpu.c b/src/util-cpu.c index 39f0db582b..2fcd435079 100644 --- a/src/util-cpu.c +++ b/src/util-cpu.c @@ -80,8 +80,10 @@ uint16_t UtilCpuGetNumProcessorsConfigured(void) const char* envvar = getenv("NUMBER_OF_PROCESSORS"); if (envvar != NULL) { if (StringParseInt64(&nprocs, 10, 0, envvar) < 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Invalid value for number of " - "processors: %s", envvar); + SCLogWarning(SC_EINVAL, + "Invalid value for number of " + "processors: %s", + envvar); return 0; } } diff --git a/src/util-device.c b/src/util-device.c index 1143286381..48a4616b0c 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -288,7 +288,7 @@ LiveDevice *LiveGetDevice(const char *name) LiveDevice *pd; if (name == NULL) { - SCLogWarning(SC_ERR_INVALID_VALUE, "Name of device should not be null"); + SCLogWarning(SC_EINVAL, "Name of device should not be null"); return NULL; } diff --git a/src/util-ebpf.c b/src/util-ebpf.c index b4a0778528..ee31526ec3 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -328,7 +328,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, } if (! path) { - SCLogError(SC_ERR_INVALID_VALUE, "No file defined to load eBPF from"); + SCLogError(SC_EINVAL, "No file defined to load eBPF from"); return -1; } @@ -347,9 +347,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, char err_buf[128]; libbpf_strerror(error, err_buf, sizeof(err_buf)); - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to load eBPF objects in '%s': %s", - path, err_buf); + SCLogError(SC_EINVAL, "Unable to load eBPF objects in '%s': %s", path, err_buf); return -1; } @@ -392,10 +390,8 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, } if (found == false) { - SCLogError(SC_ERR_INVALID_VALUE, - "No section '%s' in '%s' file. Will not be able to use the file", - section, - path); + SCLogError(SC_EINVAL, "No section '%s' in '%s' file. Will not be able to use the file", + section, path); return -1; } @@ -408,10 +404,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, } else { char buf[129]; libbpf_strerror(err, buf, sizeof(buf)); - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to load eBPF object: %s (%d)", - buf, - err); + SCLogError(SC_EINVAL, "Unable to load eBPF object: %s (%d)", buf, err); } return -1; } @@ -471,8 +464,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, * (XDP case). */ pfd = bpf_program__fd(bpfprog); if (pfd == -1) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to find %s section", section); + SCLogError(SC_EINVAL, "Unable to find %s section", section); return -1; } @@ -494,8 +486,7 @@ int EBPFSetupXDP(const char *iface, int fd, uint8_t flags) #ifdef HAVE_PACKET_XDP unsigned int ifindex = if_nametoindex(iface); if (ifindex == 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unknown interface '%s'", iface); + SCLogError(SC_EINVAL, "Unknown interface '%s'", iface); return -1; } #ifdef HAVE_BPF_XDP_ATTACH @@ -507,8 +498,7 @@ int EBPFSetupXDP(const char *iface, int fd, uint8_t flags) if (err != 0) { char buf[129]; libbpf_strerror(err, buf, sizeof(buf)); - SCLogError(SC_ERR_INVALID_VALUE, "Unable to set XDP on '%s': %s (%d)", - iface, buf, err); + SCLogError(SC_EINVAL, "Unable to set XDP on '%s': %s (%d)", iface, buf, err); return -1; } #endif @@ -826,7 +816,7 @@ static int EBPFForEachFlowV6Table(ThreadVars *th_v, uint64_t hash_cnt = 0; if (tcfg->cpus_count == 0) { - SCLogWarning(SC_ERR_INVALID_VALUE, "CPU count should not be 0"); + SCLogWarning(SC_EINVAL, "CPU count should not be 0"); return 0; } @@ -978,8 +968,7 @@ static int EBPFAddCPUToMap(const char *iface, uint32_t i) static void EBPFRedirectMapAddCPU(int i, void *data) { if (EBPFAddCPUToMap(data, i) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to add CPU %d to set", i); + SCLogError(SC_EINVAL, "Unable to add CPU %d to set", i); } else { g_redirect_iface_cpu_counter++; } @@ -990,8 +979,7 @@ void EBPFBuildCPUSet(ConfNode *node, char *iface) uint32_t key0 = 0; int mapfd = EBPFGetMapFDByName(iface, "cpus_count"); if (mapfd < 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to find 'cpus_count' map"); + SCLogError(SC_EINVAL, "Unable to find 'cpus_count' map"); return; } g_redirect_iface_cpu_counter = 0; @@ -1023,21 +1011,19 @@ int EBPFSetPeerIface(const char *iface, const char *out_iface) { int mapfd = EBPFGetMapFDByName(iface, "tx_peer"); if (mapfd < 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to find 'tx_peer' map"); + SCLogError(SC_EINVAL, "Unable to find 'tx_peer' map"); return -1; } int intmapfd = EBPFGetMapFDByName(iface, "tx_peer_int"); if (intmapfd < 0) { - SCLogError(SC_ERR_INVALID_VALUE, - "Unable to find 'tx_peer_int' map"); + SCLogError(SC_EINVAL, "Unable to find 'tx_peer_int' map"); return -1; } int key0 = 0; unsigned int peer_index = if_nametoindex(out_iface); if (peer_index == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "No iface '%s'", out_iface); + SCLogError(SC_EINVAL, "No iface '%s'", out_iface); return -1; } int ret = bpf_map_update_elem(mapfd, &key0, &peer_index, BPF_ANY); diff --git a/src/util-error.c b/src/util-error.c index 65e50b4117..c50556121f 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -156,8 +156,7 @@ const char * SCErrorToString(SCError err) CASE_CODE (SC_ERR_MULTIPLE_RUN_MODE); CASE_CODE (SC_ERR_BPF); CASE_CODE (SC_ERR_MISSING_CONFIG_PARAM); - CASE_CODE (SC_ERR_UNKNOWN_VALUE); - CASE_CODE (SC_ERR_INVALID_VALUE); + CASE_CODE(SC_ERR_UNKNOWN_VALUE); CASE_CODE (SC_ERR_UNKNOWN_REGEX_MOD); CASE_CODE (SC_ERR_INVALID_OPERATOR); CASE_CODE (SC_ERR_PCAP_RECV_INIT); diff --git a/src/util-error.h b/src/util-error.h index be7a480817..b6f9ff142f 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -158,7 +158,6 @@ typedef enum { SC_ERR_BPF, SC_ERR_BYTE_EXTRACT_FAILED, SC_ERR_UNKNOWN_VALUE, - SC_ERR_INVALID_VALUE, SC_ERR_UNKNOWN_REGEX_MOD, SC_ERR_INVALID_OPERATOR, SC_ERR_PCAP_RECV_INIT, diff --git a/src/util-hash.c b/src/util-hash.c index a2b72209ec..73ab69e235 100644 --- a/src/util-hash.c +++ b/src/util-hash.c @@ -127,7 +127,7 @@ int HashTableAdd(HashTable *ht, void *data, uint16_t datalen) hb->next = NULL; if (hash >= ht->array_size) { - SCLogWarning(SC_ERR_INVALID_VALUE, "attempt to insert element out of hash array\n"); + SCLogWarning(SC_EINVAL, "attempt to insert element out of hash array\n"); goto error; } @@ -201,7 +201,7 @@ void *HashTableLookup(HashTable *ht, void *data, uint16_t datalen) hash = ht->Hash(ht, data, datalen); if (hash >= ht->array_size) { - SCLogWarning(SC_ERR_INVALID_VALUE, "attempt to access element out of hash array\n"); + SCLogWarning(SC_EINVAL, "attempt to access element out of hash array\n"); return NULL; } diff --git a/src/util-host-info.c b/src/util-host-info.c index eac28fe212..08d1ff1813 100644 --- a/src/util-host-info.c +++ b/src/util-host-info.c @@ -48,8 +48,7 @@ int SCKernelVersionIsAtLeast(int major, int minor) /* get local version */ if (uname(&kuname) != 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid uname return: %s", - strerror(errno)); + SCLogError(SC_EINVAL, "Invalid uname return: %s", strerror(errno)); return 0; } @@ -85,11 +84,11 @@ int SCKernelVersionIsAtLeast(int major, int minor) bool err = false; if (StringParseInt32(&kmajor, 10, 0, (const char *)list[1]) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for kmajor: '%s'", list[1]); + SCLogError(SC_EINVAL, "Invalid value for kmajor: '%s'", list[1]); err = true; } if (StringParseInt32(&kminor, 10, 0, (const char *)list[2]) < 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for kminor: '%s'", list[2]); + SCLogError(SC_EINVAL, "Invalid value for kminor: '%s'", list[2]); err = true; } diff --git a/src/util-ja3.c b/src/util-ja3.c index dbbf28063f..eeadecd403 100644 --- a/src/util-ja3.c +++ b/src/util-ja3.c @@ -219,7 +219,7 @@ char *Ja3GenerateHash(JA3Buffer *buffer) } if (buffer->data == NULL) { - SCLogError(SC_ERR_INVALID_VALUE, "Buffer data should not be NULL"); + SCLogError(SC_EINVAL, "Buffer data should not be NULL"); return NULL; } diff --git a/src/util-log-redis.c b/src/util-log-redis.c index cec126505a..57aad70378 100644 --- a/src/util-log-redis.c +++ b/src/util-log-redis.c @@ -387,9 +387,7 @@ static int SCLogRedisWriteSync(LogFileCtx *file_ctx, const char *string) } break; default: - SCLogWarning(SC_ERR_INVALID_VALUE, - "Unsupported error code %d", - redis->err); + SCLogWarning(SC_EINVAL, "Unsupported error code %d", redis->err); return -1; } } @@ -414,8 +412,7 @@ static int SCLogRedisWriteSync(LogFileCtx *file_ctx, const char *string) ret = 0; break; default: - SCLogError(SC_ERR_INVALID_VALUE, - "Redis default triggered with %d", reply->type); + SCLogError(SC_EINVAL, "Redis default triggered with %d", reply->type); SCConfLogReopenSyncRedis(file_ctx); break; } @@ -538,7 +535,7 @@ int SCConfLogOpenRedis(ConfNode *redis_node, void *lf_ctx) FatalError(SC_ERR_FATAL, "Error allocating redis server string"); } if (StringParseUint16(&log_ctx->redis_setup.port, 10, 0, (const char *)redis_port) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Invalid value for redis port: %s", redis_port); + FatalError(SC_EINVAL, "Invalid value for redis port: %s", redis_port); } log_ctx->Close = SCLogFileCloseRedis; diff --git a/src/util-napatech.c b/src/util-napatech.c index b61aa85dd4..05aa4a8f09 100644 --- a/src/util-napatech.c +++ b/src/util-napatech.c @@ -763,16 +763,22 @@ static uint32_t CountWorkerThreads(void) if (StringParseUint8(&start, 10, end_str - lnode->val, (const char *)lnode->val) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid" - " worker range start: '%s'", lnode->val); + FatalError(SC_EINVAL, + "Napatech invalid" + " worker range start: '%s'", + lnode->val); } if (StringParseUint8(&end, 10, 0, (const char *) (end_str + 1)) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid" - " worker range end: '%s'", (end_str != NULL) ? (const char *)(end_str + 1) : "Null"); + FatalError(SC_EINVAL, + "Napatech invalid" + " worker range end: '%s'", + (end_str != NULL) ? (const char *)(end_str + 1) : "Null"); } if (end < start) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid" - " worker range start: '%d' is greater than end: '%d'", start, end); + FatalError(SC_EINVAL, + "Napatech invalid" + " worker range start: '%d' is greater than end: '%d'", + start, end); } worker_count = end - start + 1; @@ -918,12 +924,16 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) if (StringParseUint8(&start, 10, end_str - stream->val, (const char *)stream->val) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid " - "stream id start: '%s'", stream->val); + FatalError(SC_EINVAL, + "Napatech invalid " + "stream id start: '%s'", + stream->val); } if (StringParseUint8(&end, 10, 0, (const char *) (end_str + 1)) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid " - "stream id end: '%s'", (end_str != NULL) ? (const char *)(end_str + 1) : "Null"); + FatalError(SC_EINVAL, + "Napatech invalid " + "stream id end: '%s'", + (end_str != NULL) ? (const char *)(end_str + 1) : "Null"); } } else { if (stream_spec == CONFIG_SPECIFIER_RANGE) { @@ -933,8 +943,10 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) stream_spec = CONFIG_SPECIFIER_INDIVIDUAL; if (StringParseUint8(&stream_config[instance_cnt].stream_id, 10, 0, (const char *)stream->val) < 0) { - FatalError(SC_ERR_INVALID_VALUE, "Napatech invalid " - "stream id: '%s'", stream->val); + FatalError(SC_EINVAL, + "Napatech invalid " + "stream id: '%s'", + stream->val); } start = stream_config[instance_cnt].stream_id; end = stream_config[instance_cnt].stream_id; diff --git a/src/util-print.c b/src/util-print.c index efef902163..47a9bec1b3 100644 --- a/src/util-print.c +++ b/src/util-print.c @@ -290,7 +290,7 @@ const char *PrintInet(int af, const void *src, char *dst, socklen_t size) /* Format IPv6 without deleting zeroes */ return PrintInetIPv6(src, dst, size); default: - SCLogError(SC_ERR_INVALID_VALUE, "Unsupported protocol: %d", af); + SCLogError(SC_EINVAL, "Unsupported protocol: %d", af); } return NULL; } diff --git a/src/util-runmodes.c b/src/util-runmodes.c index 3510a5ec43..0089474fad 100644 --- a/src/util-runmodes.c +++ b/src/util-runmodes.c @@ -296,13 +296,13 @@ static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc Mod tm_module = TmModuleGetByName(recv_mod_name); if (tm_module == NULL) { - FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName failed for %s", recv_mod_name); + FatalError(SC_EINVAL, "TmModuleGetByName failed for %s", recv_mod_name); } TmSlotSetFuncAppend(tv, tm_module, aconf); tm_module = TmModuleGetByName(decode_mod_name); if (tm_module == NULL) { - FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName %s failed", decode_mod_name); + FatalError(SC_EINVAL, "TmModuleGetByName %s failed", decode_mod_name); } TmSlotSetFuncAppend(tv, tm_module, NULL); @@ -547,13 +547,13 @@ int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser, tm_module = TmModuleGetByName(recv_mod_name); if (tm_module == NULL) { - FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName failed for %s", recv_mod_name); + FatalError(SC_EINVAL, "TmModuleGetByName failed for %s", recv_mod_name); } TmSlotSetFuncAppend(tv, tm_module, (void *) ConfigParser(i)); tm_module = TmModuleGetByName(decode_mod_name); if (tm_module == NULL) { - FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName %s failed", decode_mod_name); + FatalError(SC_EINVAL, "TmModuleGetByName %s failed", decode_mod_name); } TmSlotSetFuncAppend(tv, tm_module, NULL); diff --git a/src/util-spm.c b/src/util-spm.c index d3251a8e39..095132e0c0 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -85,8 +85,8 @@ uint16_t SinglePatternMatchDefaultMatcher(void) #ifndef BUILD_HYPERSCAN if ((spm_algo != NULL) && (strcmp(spm_algo, "hs") == 0)) { - FatalError(SC_ERR_INVALID_VALUE, "Hyperscan (hs) support for spm-algo is " - "not compiled into Suricata."); + FatalError(SC_EINVAL, "Hyperscan (hs) support for spm-algo is " + "not compiled into Suricata."); } #endif SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, diff --git a/src/util-storage.c b/src/util-storage.c index 4efc2333ae..8f61ed34f7 100644 --- a/src/util-storage.c +++ b/src/util-storage.c @@ -109,9 +109,10 @@ int StorageRegister(const StorageEnum type, const char *name, const unsigned int StorageList *list = storage_list; while (list) { if (strcmp(name, list->map.name) == 0 && type == list->map.type) { - SCLogError(SC_ERR_INVALID_VALUE, "storage for type \"%s\" with " - "name \"%s\" already registered", StoragePrintType(type), - name); + SCLogError(SC_EINVAL, + "storage for type \"%s\" with " + "name \"%s\" already registered", + StoragePrintType(type), name); return -1; } diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index dc9d3a9b79..7a7024143b 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -391,9 +391,9 @@ static int SetupSuppressRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid, SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_SUPPRESS); } } else if (id > 0 && gid == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Can't use a event config that has " - "sid > 0 and gid == 0. Please fix this " - "in your threshold.config file"); + SCLogError(SC_EINVAL, "Can't use a event config that has " + "sid > 0 and gid == 0. Please fix this " + "in your threshold.config file"); goto error; } else { s = SigFindSignatureBySidGid(de_ctx, id, gid); @@ -548,9 +548,9 @@ static int SetupThresholdRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid } } } else if (id > 0 && gid == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "Can't use a event config that has " - "sid > 0 and gid == 0. Please fix this " - "in your threshold.conf file"); + SCLogError(SC_EINVAL, "Can't use a event config that has " + "sid > 0 and gid == 0. Please fix this " + "in your threshold.conf file"); } else { s = SigFindSignatureBySidGid(de_ctx, id, gid); if (s == NULL) { @@ -709,7 +709,7 @@ static int ParseThresholdRule(const DetectEngineCtx *de_ctx, char *rawstr, uint3 } else if (strcasecmp(th_rule_type,"suppress") == 0) { rule_type = THRESHOLD_TYPE_SUPPRESS; } else { - SCLogError(SC_ERR_INVALID_VALUE, "rule type %s is unknown", th_rule_type); + SCLogError(SC_EINVAL, "rule type %s is unknown", th_rule_type); goto error; } @@ -901,7 +901,7 @@ static int ParseThresholdRule(const DetectEngineCtx *de_ctx, char *rawstr, uint3 else if (strcasecmp(th_track,"by_rule") == 0) parsed_track = TRACK_RULE; else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid track parameter %s in %s", th_track, rawstr); + SCLogError(SC_EINVAL, "Invalid track parameter %s in %s", th_track, rawstr); goto error; } @@ -909,7 +909,7 @@ static int ParseThresholdRule(const DetectEngineCtx *de_ctx, char *rawstr, uint3 goto error; } if (parsed_count == 0) { - SCLogError(SC_ERR_INVALID_VALUE, "rate filter count should be > 0"); + SCLogError(SC_EINVAL, "rate filter count should be > 0"); goto error; } @@ -929,7 +929,8 @@ static int ParseThresholdRule(const DetectEngineCtx *de_ctx, char *rawstr, uint3 parsed_track = TRACK_EITHER; } else { - SCLogError(SC_ERR_INVALID_VALUE, "Invalid track parameter %s in %s", th_track, rule_extend); + SCLogError( + SC_EINVAL, "Invalid track parameter %s in %s", th_track, rule_extend); goto error; } } -- 2.47.2