]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
src: use FatalError whenever possible
authorShivani Bhardwaj <shivanib134@gmail.com>
Thu, 9 Jul 2020 09:01:01 +0000 (14:31 +0530)
committerVictor Julien <victor@inliniac.net>
Sat, 11 Jul 2020 06:37:07 +0000 (08:37 +0200)
Replaces all patterns of SCLogError() followed by exit() with
FatalError(). Cocci script to do this:

@@
constant C;
constant char[] msg;
@@

- SCLogError(C,
+ FatalError(SC_ERR_FATAL,
  msg);
- exit(EXIT_FAILURE);

Closes redmine ticket 3188.

71 files changed:
src/app-layer-detect-proto.c
src/app-layer-htp.c
src/app-layer-parser.c
src/conf-yaml-loader.c
src/conf.c
src/counters.c
src/defrag-config.c
src/defrag-hash.c
src/defrag.c
src/detect-engine-analyzer.c
src/detect-engine-build.c
src/detect-engine-iponly.c
src/detect-engine-mpm.c
src/detect-engine-sigorder.c
src/detect-engine-tag.c
src/detect-engine-threshold.c
src/detect-parse.c
src/flow.c
src/host-bit.c
src/host.c
src/ippair-bit.c
src/ippair.c
src/log-pcap.c
src/output-json.c
src/output-lua.c
src/output-tx.c
src/output.c
src/reputation.c
src/runmode-af-packet.c
src/runmode-erf-dag.c
src/runmode-erf-file.c
src/runmode-napatech.c
src/runmode-netmap.c
src/runmode-nflog.c
src/runmode-pcap-file.c
src/runmode-pcap.c
src/runmode-pfring.c
src/runmode-unittests.c
src/runmodes.c
src/source-erf-dag.c
src/source-napatech.c
src/source-nflog.c
src/source-nfq.c
src/stream-tcp.c
src/suricata.c
src/tm-threads.c
src/tmqh-packetpool.c
src/unix-manager.c
src/util-affinity.c
src/util-daemon.c
src/util-debug-filters.c
src/util-debug.c
src/util-host-os-info.c
src/util-ip.c
src/util-log-redis.c
src/util-logopenfile.c
src/util-mpm-ac-bs.c
src/util-mpm-ac-ks.c
src/util-mpm-ac.c
src/util-mpm-hs.c
src/util-mpm.c
src/util-napatech.c
src/util-privs.c
src/util-profiling-keywords.c
src/util-profiling-prefilter.c
src/util-profiling-rulegroups.c
src/util-profiling-rules.c
src/util-profiling.c
src/util-radix-tree.c
src/util-spm-bm.c
src/util-thash.c

index d7f0c67d7df3c1150829e0a34926b8165cbb2500..3bc4c537b88f04e5b19a4a853e42ebbea8e8b328 100644 (file)
@@ -1661,11 +1661,9 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name,
     r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
                  alproto_name, ".detection-ports");
     if (r < 0) {
-        SCLogError(SC_ERR_FATAL, "snprintf failure.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "snprintf failure.");
     } else if (r > (int)sizeof(param)) {
-        SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
     }
     node = ConfGetNode(param);
     if (node == NULL) {
@@ -1673,11 +1671,9 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name,
         r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
                      alproto_name, ".", ipproto_name, ".detection-ports");
         if (r < 0) {
-            SCLogError(SC_ERR_FATAL, "snprintf failure.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "snprintf failure.");
         } else if (r > (int)sizeof(param)) {
-            SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
         }
         node = ConfGetNode(param);
         if (node == NULL)
@@ -1775,8 +1771,7 @@ int AppLayerProtoDetectSetup(void)
 
     alpd_ctx.spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
     if (alpd_ctx.spm_global_thread_ctx == NULL) {
-        SCLogError(SC_ERR_FATAL, "Unable to alloc SpmGlobalThreadCtx.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to alloc SpmGlobalThreadCtx.");
     }
 
     for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
@@ -1905,11 +1900,9 @@ int AppLayerProtoDetectConfProtoDetectionEnabled(const char *ipproto,
     r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
                  alproto, ".enabled");
     if (r < 0) {
-        SCLogError(SC_ERR_FATAL, "snprintf failure.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "snprintf failure.");
     } else if (r > (int)sizeof(param)) {
-        SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
     }
 
     node = ConfGetNode(param);
@@ -1918,11 +1911,9 @@ int AppLayerProtoDetectConfProtoDetectionEnabled(const char *ipproto,
         r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
                      alproto, ".", ipproto, ".enabled");
         if (r < 0) {
-            SCLogError(SC_ERR_FATAL, "snprintf failure.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "snprintf failure.");
         } else if (r > (int)sizeof(param)) {
-            SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
         }
 
         node = ConfGetNode(param);
index 4bc26f06dac47a87bf3309005062817de60ef333..12b66f901b24b41a19e6a14bab83ebcf3fa3ba73 100644 (file)
@@ -2747,9 +2747,8 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s,
                 exit(EXIT_FAILURE);
             }
             if (limit == 0) {
-                SCLogError(SC_ERR_SIZE_PARSE, "Error meta-field-limit "
+                FatalError(SC_ERR_FATAL, "Error meta-field-limit "
                            "from conf file cannot be 0.  Killing engine");
-                exit(EXIT_FAILURE);
             }
             /* set default soft-limit with our new hard limit */
             htp_config_set_field_limits(cfg_prec->cfg,
@@ -2890,8 +2889,7 @@ void HTPConfigure(void)
     /* Default Config */
     cfglist.cfg = htp_config_create();
     if (NULL == cfglist.cfg) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to create HTP default config");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to create HTP default config");
     }
     SCLogDebug("LIBHTP default config: %p", cfglist.cfg);
     HTPConfigSetDefaultsPhase1(&cfglist);
@@ -2939,8 +2937,7 @@ void HTPConfigure(void)
         cfglist.next->next = nextrec;
         cfglist.next->cfg = htp_config_create();
         if (NULL == cfglist.next->cfg) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to create HTP server config");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Failed to create HTP server config");
         }
 
         HTPConfigSetDefaultsPhase1(htprec);
index b2c11dbbb859da950eee07008e01b9b651716464..5009a48419eb3f4b924be8b44b32d11c7c0ca049 100644 (file)
@@ -315,11 +315,9 @@ int AppLayerParserConfParserEnabled(const char *ipproto,
     r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
                  alproto_name, ".enabled");
     if (r < 0) {
-        SCLogError(SC_ERR_FATAL, "snprintf failure.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "snprintf failure.");
     } else if (r > (int)sizeof(param)) {
-        SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
     }
 
     node = ConfGetNode(param);
@@ -328,11 +326,9 @@ int AppLayerParserConfParserEnabled(const char *ipproto,
         r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
                      alproto_name, ".", ipproto, ".enabled");
         if (r < 0) {
-            SCLogError(SC_ERR_FATAL, "snprintf failure.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "snprintf failure.");
         } else if (r > (int)sizeof(param)) {
-            SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
         }
 
         node = ConfGetNode(param);
index b6f014231d231ab29e48cdcc39b172bf428a9881..d6bb378963ddd8b8fa74381f53fa17b732b500d7 100644 (file)
@@ -92,17 +92,15 @@ ConfYamlSetConfDirname(const char *filename)
     if (ep == NULL) {
         conf_dirname = SCStrdup(".");
         if (conf_dirname == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-               "ERROR: Failed to allocate memory while loading configuration.");
-            exit(EXIT_FAILURE);
+               FatalError(SC_ERR_FATAL,
+                          "ERROR: Failed to allocate memory while loading configuration.");
         }
     }
     else {
         conf_dirname = SCStrdup(filename);
         if (conf_dirname == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-               "ERROR: Failed to allocate memory while loading configuration.");
-            exit(EXIT_FAILURE);
+               FatalError(SC_ERR_FATAL,
+                          "ERROR: Failed to allocate memory while loading configuration.");
         }
         conf_dirname[ep - filename] = '\0';
     }
index 64b00ebc3a0d9d826f8bc6f429076988c5343fc7..633486a6f8271d5c83ea2d4c478bc32ac10709ca 100644 (file)
@@ -118,10 +118,9 @@ void ConfInit(void)
     }
     root = ConfNodeNew();
     if (root == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "ERROR: Failed to allocate memory for root configuration node, "
-            "aborting.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "ERROR: Failed to allocate memory for root configuration node, "
+                       "aborting.");
     }
     SCLogDebug("configuration module initialized");
 }
index a9ff3c405ba9d1dcb839395a7b5ab90fd467dada..b1c64f2cd9f18d4f806f0cad6019318b6e5a10e4 100644 (file)
@@ -286,8 +286,7 @@ static void StatsInitCtxPostOutput(void)
 
     /* init the lock used by StatsThreadStore */
     if (SCMutexInit(&stats_ctx->sts_lock, NULL) != 0) {
-        SCLogError(SC_ERR_INITIALIZATION, "error initializing sts mutex");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "error initializing sts mutex");
     }
 
     if (stats_enabled && !OutputStatsLoggersRegistered()) {
@@ -863,8 +862,8 @@ void StatsInit(void)
 {
     BUG_ON(stats_ctx != NULL);
     if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in StatsInitCtx. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in StatsInitCtx. Exiting...");
     }
     memset(stats_ctx, 0, sizeof(StatsGlobalContext));
 
@@ -903,30 +902,25 @@ void StatsSpawnThreads(void)
     tv_wakeup = TmThreadCreateMgmtThread(thread_name_counter_wakeup,
                                          StatsWakeupThread, 1);
     if (tv_wakeup == NULL) {
-        SCLogError(SC_ERR_THREAD_CREATE, "TmThreadCreateMgmtThread "
+        FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread "
                    "failed");
-        exit(EXIT_FAILURE);
     }
 
     if (TmThreadSpawn(tv_wakeup) != 0) {
-        SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
+        FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
                    "StatsWakeupThread");
-        exit(EXIT_FAILURE);
     }
 
     /* spawn the stats mgmt thread */
     tv_mgmt = TmThreadCreateMgmtThread(thread_name_counter_stats,
                                        StatsMgmtThread, 1);
     if (tv_mgmt == NULL) {
-        SCLogError(SC_ERR_THREAD_CREATE,
-                   "TmThreadCreateMgmtThread failed");
-        exit(EXIT_FAILURE);
+                   FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread failed");
     }
 
     if (TmThreadSpawn(tv_mgmt) != 0) {
-        SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
+        FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
                    "StatsWakeupThread");
-        exit(EXIT_FAILURE);
     }
 
     SCReturn;
index a1e1b4f94a94c557b650c92e7a6282a3edfc6b30..f5d0f89e0bd2311bc2dde2f8a9ad8a46de8bbcc4 100644 (file)
@@ -47,8 +47,7 @@ static void DefragPolicyAddHostInfo(char *host_ip_range, uint64_t timeout)
     uint64_t *user_data = NULL;
 
     if ( (user_data = SCMalloc(sizeof(uint64_t))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
     }
 
     *user_data = timeout;
@@ -137,9 +136,8 @@ void DefragPolicyLoadFromConfig(void)
 
     defrag_tree = SCRadixCreateRadixTree(DefragPolicyFreeUserData, NULL);
     if (defrag_tree == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Can't alloc memory for the defrag config tree.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Can't alloc memory for the defrag config tree.");
     }
 
     ConfNode *server_config = ConfGetNode("defrag.host-config");
index 88a8228560bd13020f9fde6f509607d24bafe3b9..317a0122d0c5a5b5e30937a64d47241722d31e1c 100644 (file)
@@ -236,8 +236,8 @@ void DefragInitConfig(char quiet)
     }
     defragtracker_hash = SCCalloc(defrag_config.hash_size, sizeof(DefragTrackerHashRow));
     if (unlikely(defragtracker_hash == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
     }
     memset(defragtracker_hash, 0, defrag_config.hash_size * sizeof(DefragTrackerHashRow));
 
index fa66ff611e293a1e7f43560e9e4eb11b7668d2d0..6b68f09bed13c7be7141de1f1afa447c5dd1f92f 100644 (file)
@@ -196,14 +196,12 @@ DefragContextNew(void)
         sizeof(Frag),
         NULL, DefragFragInit, dc, NULL, NULL);
     if (dc->frag_pool == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Defrag: Failed to initialize fragment pool.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Defrag: Failed to initialize fragment pool.");
     }
     if (SCMutexInit(&dc->frag_pool_lock, NULL) != 0) {
-        SCLogError(SC_ERR_MUTEX,
-            "Defrag: Failed to initialize frag pool mutex.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Defrag: Failed to initialize frag pool mutex.");
     }
 
     /* Set the default timeout. */
@@ -213,14 +211,12 @@ DefragContextNew(void)
     }
     else {
         if (timeout < TIMEOUT_MIN) {
-            SCLogError(SC_ERR_INVALID_ARGUMENT,
-                "defrag: Timeout less than minimum allowed value.");
-            exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "defrag: Timeout less than minimum allowed value.");
         }
         else if (timeout > TIMEOUT_MAX) {
-            SCLogError(SC_ERR_INVALID_ARGUMENT,
-                "defrag: Tiemout greater than maximum allowed value.");
-            exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "defrag: Tiemout greater than maximum allowed value.");
         }
         dc->timeout = timeout;
     }
@@ -1078,9 +1074,8 @@ DefragInit(void)
     /* Allocate the DefragContext. */
     defrag_context = DefragContextNew();
     if (defrag_context == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate memory for the Defrag module.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Failed to allocate memory for the Defrag module.");
     }
 
     DefragSetDefaultTimeout(defrag_context->timeout);
index 895e18e517dc15a76143c1bae42e4a9d748ecf00..9f33f5003dc764ed989b60a0a86a4c50367cc801 100644 (file)
@@ -238,8 +238,7 @@ void EngineAnalysisFP(const DetectEngineCtx *de_ctx, const Signature *s, char *l
     uint16_t patlen = fp_cd->content_len;
     uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
     if (unlikely(pat == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memcpy(pat, fp_cd->content, fp_cd->content_len);
     pat[fp_cd->content_len] = '\0';
@@ -486,8 +485,7 @@ static void EngineAnalysisRulesPrintFP(const DetectEngineCtx *de_ctx, const Sign
     uint16_t patlen = fp_cd->content_len;
     uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
     if (unlikely(pat == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memcpy(pat, fp_cd->content, fp_cd->content_len);
     pat[fp_cd->content_len] = '\0';
@@ -634,8 +632,7 @@ static void DumpMatches(RuleAnalyzer *ctx, json_t *js, const SigMatchData *smd)
                     const DetectContentData *cd = (const DetectContentData *)smd->ctx;
                     uint8_t *pat = SCMalloc(cd->content_len + 1);
                     if (unlikely(pat == NULL)) {
-                        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                        exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL, "Error allocating memory");
                     }
                     memcpy(pat, cd->content, cd->content_len);
                     pat[cd->content_len] = '\0';
index 36edfcdba5d0ff5ffbae411c79f8441d765f1cf2..099e3583512aef4696cfd5d1b1a13c3d2f2ab15e 100644 (file)
@@ -1897,35 +1897,29 @@ int SigGroupBuild(DetectEngineCtx *de_ctx)
     SigInitStandardMpmFactoryContexts(de_ctx);
 
     if (SigAddressPrepareStage1(de_ctx) != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
 
     if (SigAddressPrepareStage2(de_ctx) != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
 
     if (SigAddressPrepareStage3(de_ctx) != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
     if (SigAddressPrepareStage4(de_ctx) != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
 
     int r = DetectMpmPrepareBuiltinMpms(de_ctx);
     r |= DetectMpmPrepareAppMpms(de_ctx);
     r |= DetectMpmPreparePktMpms(de_ctx);
     if (r != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
 
     if (SigMatchPrepare(de_ctx) != 0) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
 
 #ifdef PROFILING
index d8fbc5e66bba0a8b279493c50d518077f215c92e..521d2accf3943c8ea1f558b4d0fe28b4e800ac85 100644 (file)
@@ -531,8 +531,8 @@ static SigNumArray *SigNumArrayNew(DetectEngineCtx *de_ctx,
     SigNumArray *new = SCMalloc(sizeof(SigNumArray));
 
     if (unlikely(new == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayNew. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SigNumArrayNew. Exiting...");
     }
     memset(new, 0, sizeof(SigNumArray));
 
@@ -562,8 +562,8 @@ static SigNumArray *SigNumArrayCopy(SigNumArray *orig)
     SigNumArray *new = SCMalloc(sizeof(SigNumArray));
 
     if (unlikely(new == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayCopy. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SigNumArrayCopy. Exiting...");
     }
 
     memset(new, 0, sizeof(SigNumArray));
@@ -874,8 +874,8 @@ void IPOnlyInit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx)
     io_ctx->sig_init_size = DetectEngineGetMaxSigId(de_ctx) / 8 + 1;
 
     if ( (io_ctx->sig_init_array = SCMalloc(io_ctx->sig_init_size)) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in IPOnlyInit. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in IPOnlyInit. Exiting...");
     }
 
     memset(io_ctx->sig_init_array, 0, io_ctx->sig_init_size);
index 21a45d8c231eb61b1b0bb50d228443bd6d8791bc..301b360bf51aa304459f0384797551704fd3bb07 100644 (file)
@@ -624,9 +624,8 @@ uint16_t PatternMatchDefaultMatcher(void)
         if (mpm_algo != NULL) {
 #if __BYTE_ORDER == __BIG_ENDIAN
             if (strcmp(mpm_algo, "ac-ks") == 0) {
-                SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "ac-ks does "
-                        "not work on big endian systems at this time.");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "ac-ks does "
+                           "not work on big endian systems at this time.");
             }
 #endif
             if (strcmp("auto", mpm_algo) == 0) {
index 55be9c8410bb1d80076a6b32bc8aa32d4cb86df9..6cfa2d9e8aaf46ec47131ffd9450d6a6da55215d 100644 (file)
@@ -97,8 +97,8 @@ static void SCSigRegisterSignatureOrderingFunc(DetectEngineCtx *de_ctx,
     }
 
     if ( (temp = SCMalloc(sizeof(SCSigOrderFunc))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
     }
     memset(temp, 0, sizeof(SCSigOrderFunc));
 
index 5ae72cc0fbd26353e4a325de5d920b5a38f00393..f9d15a194b06e8cad6117b335c87e239821cfc06 100644 (file)
@@ -54,13 +54,11 @@ void TagInitCtx(void)
 
     host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
     if (host_tag_id == -1) {
-        SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for tag");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Can't initiate host storage for tag");
     }
     flow_tag_id = FlowStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
     if (flow_tag_id == -1) {
-        SCLogError(SC_ERR_FLOW_INIT, "Can't initiate flow storage for tag");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Can't initiate flow storage for tag");
     }
 }
 
index 0701403fd40a30488ffcab6fc8218399616e1026..eff4fe4f6b37f245be9f803761444a15985abc96 100644 (file)
@@ -81,13 +81,13 @@ void ThresholdInit(void)
 {
     host_threshold_id = HostStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
     if (host_threshold_id == -1) {
-        SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for thresholding");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Can't initiate host storage for thresholding");
     }
     ippair_threshold_id = IPPairStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
     if (ippair_threshold_id == -1) {
-        SCLogError(SC_ERR_HOST_INIT, "Can't initiate IP pair storage for thresholding");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Can't initiate IP pair storage for thresholding");
     }
 }
 
@@ -652,9 +652,8 @@ int PacketAlertThreshold(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx
 void ThresholdHashInit(DetectEngineCtx *de_ctx)
 {
     if (SCMutexInit(&de_ctx->ths_ctx.threshold_table_lock, NULL) != 0) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                "Threshold: Failed to initialize hash table mutex.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Threshold: Failed to initialize hash table mutex.");
     }
 }
 
index d6956b62637a7d35d24f9cc326197f8505cc37fc..69cdb5a33a11e62794cae55ca58b87a2a15c9f48 100644 (file)
@@ -1610,8 +1610,7 @@ SigMatchData* SigMatchList2DataArray(SigMatch *head)
 
     SigMatchData *smd = (SigMatchData *)SCCalloc(len, sizeof(SigMatchData));
     if (smd == NULL) {
-        SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
     }
     SigMatchData *out = smd;
 
index 93c49896fd5c77c1925ea5639d171a312849a361..ad0001441ec681abc7d64d35dd404613bf39c847 100644 (file)
@@ -570,8 +570,7 @@ void FlowInitConfig(char quiet)
     if ((ConfGet("flow.memcap", &conf_val)) == 1)
     {
         if (conf_val == NULL) {
-            SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.memcap: NULL");
-           exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Invalid value for flow.memcap: NULL");
         }
 
         if (ParseSizeStringU64(conf_val, &flow_memcap_copy) < 0) {
@@ -586,8 +585,7 @@ void FlowInitConfig(char quiet)
     if ((ConfGet("flow.hash-size", &conf_val)) == 1)
     {
         if (conf_val == NULL) {
-            SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.hash-size: NULL");
-           exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Invalid value for flow.hash-size: NULL");
         }
 
         if (StringParseUint32(&configval, 10, strlen(conf_val),
@@ -598,8 +596,7 @@ void FlowInitConfig(char quiet)
     if ((ConfGet("flow.prealloc", &conf_val)) == 1)
     {
         if (conf_val == NULL) {
-            SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.prealloc: NULL");
-           exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Invalid value for flow.prealloc: NULL");
         }
 
         if (StringParseUint32(&configval, 10, strlen(conf_val),
@@ -624,8 +621,8 @@ void FlowInitConfig(char quiet)
     }
     flow_hash = SCMallocAligned(flow_config.hash_size * sizeof(FlowBucket), CLS);
     if (unlikely(flow_hash == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowInitConfig. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in FlowInitConfig. Exiting...");
     }
     memset(flow_hash, 0, flow_config.hash_size * sizeof(FlowBucket));
 
index 7eeeaab2afd49da050c3ef49146b722f86aedac0..7df8501317a78d9e7497df6fa444f0b72cb9c98c 100644 (file)
@@ -50,8 +50,7 @@ void HostBitInitCtx(void)
 {
     host_bit_id = HostStorageRegister("bit", sizeof(void *), NULL, HostBitFreeAll);
     if (host_bit_id == -1) {
-        SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for bits");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Can't initiate host storage for bits");
     }
 }
 
index efbc1528aa9d93cda3edb95e62e339ae3ccc216e..671faf1b11df991fa609a77eac5879a575ce8357 100644 (file)
@@ -241,8 +241,8 @@ void HostInitConfig(char quiet)
     }
     host_hash = SCMallocAligned(host_config.hash_size * sizeof(HostHashRow), CLS);
     if (unlikely(host_hash == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostInitConfig. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in HostInitConfig. Exiting...");
     }
     memset(host_hash, 0, host_config.hash_size * sizeof(HostHashRow));
 
index 0564217cc8f9b10d10cc5c77b990576ec5afcc50..aacf21fb3ff1a3f06a523246dac9c70223bf7c3d 100644 (file)
@@ -50,8 +50,7 @@ void IPPairBitInitCtx(void)
 {
     ippair_bit_id = IPPairStorageRegister("bit", sizeof(void *), NULL, XBitFreeAll);
     if (ippair_bit_id == -1) {
-        SCLogError(SC_ERR_IPPAIR_INIT, "Can't initiate ippair storage for bits");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Can't initiate ippair storage for bits");
     }
 }
 
index 900cb2fb85906dbb687aa2bb13632377df5ce609..b82a196e7eca0c91259ab60d744ff884c49201ca 100644 (file)
@@ -236,8 +236,8 @@ void IPPairInitConfig(char quiet)
     }
     ippair_hash = SCMallocAligned(ippair_config.hash_size * sizeof(IPPairHashRow), CLS);
     if (unlikely(ippair_hash == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in IPPairInitConfig. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in IPPairInitConfig. Exiting...");
     }
     memset(ippair_hash, 0, ippair_config.hash_size * sizeof(IPPairHashRow));
 
index dda5fbbc5cf7ee966d96d73b452033114646b022..afee53c0927ac67c74c859fdaad6408e05f4df96 100644 (file)
@@ -1170,16 +1170,14 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
 
     PcapLogData *pl = SCMalloc(sizeof(PcapLogData));
     if (unlikely(pl == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate Memory for PcapLogData");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to allocate Memory for PcapLogData");
     }
     memset(pl, 0, sizeof(PcapLogData));
 
     pl->h = SCMalloc(sizeof(*pl->h));
     if (pl->h == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate Memory for pcap header struct");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Failed to allocate Memory for pcap header struct");
     }
 
     /* Set the defaults */
@@ -1246,10 +1244,9 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
                 uint64_t size = pl->size_limit * 1024 * 1024;
                 pl->size_limit = size;
             } else if (pl->size_limit < MIN_LIMIT) {
-                SCLogError(SC_ERR_INVALID_ARGUMENT,
-                    "Fail to initialize pcap-log output, limit less than "
-                    "allowed minimum.");
-                exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Fail to initialize pcap-log output, limit less than "
+                               "allowed minimum.");
             }
         }
     }
@@ -1277,10 +1274,9 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
         }
         if (s_dir == NULL) {
             if (pl->mode == LOGMODE_SGUIL) {
-                SCLogError(SC_ERR_LOGPCAP_SGUIL_BASE_DIR_MISSING,
-                    "log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
-                    "option to be set.");
-                exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
+                               "option to be set.");
             } else {
                 const char *log_dir = NULL;
                 log_dir = ConfigGetLogDirectory();
@@ -1394,9 +1390,8 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
 
             comp->buffer = SCMalloc(comp->buffer_size);
             if (unlikely(comp->buffer == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for "
-                    "lz4 output buffer.");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Failed to allocate memory for "
+                           "lz4 output buffer.");
             }
 
             comp->bytes_in_block = 0;
@@ -1438,10 +1433,9 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
                            max_number_of_files_s);
                 exit(EXIT_FAILURE);
             } else if (max_file_limit < 1) {
-                SCLogError(SC_ERR_INVALID_ARGUMENT,
-                    "Failed to initialize pcap-log output, limit less than "
-                    "allowed minimum.");
-                exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to initialize pcap-log output, limit less than "
+                               "allowed minimum.");
             } else {
                 pl->max_files = max_file_limit;
                 pl->use_ringbuffer = RING_BUFFER_MODE_ENABLED;
@@ -1474,9 +1468,8 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
         } else if (ConfValIsTrue(use_stream_depth)) {
             pl->use_stream_depth = USE_STREAM_DEPTH_ENABLED;
         } else {
-            SCLogError(SC_ERR_INVALID_ARGUMENT,
-                "log-pcap use_stream_depth specified is invalid must be");
-            exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "log-pcap use_stream_depth specified is invalid must be");
         }
     }
 
@@ -1490,9 +1483,8 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
         } else if (ConfValIsTrue(honor_pass_rules)) {
             pl->honor_pass_rules = HONOR_PASS_RULES_ENABLED;
         } else {
-            SCLogError(SC_ERR_INVALID_ARGUMENT,
-                "log-pcap honor-pass-rules specified is invalid");
-            exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "log-pcap honor-pass-rules specified is invalid");
         }
     }
 
@@ -1500,8 +1492,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
     if (unlikely(output_ctx == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for OutputCtx.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to allocate memory for OutputCtx.");
     }
     output_ctx->data = pl;
     output_ctx->DeInit = PcapLogFileDeInitCtx;
@@ -1828,8 +1819,7 @@ void PcapLogProfileSetup(void)
 
             profiling_pcaplog_file_name = SCMalloc(PATH_MAX);
             if (unlikely(profiling_pcaplog_file_name == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "can't duplicate file name");
             }
 
             snprintf(profiling_pcaplog_file_name, PATH_MAX, "%s/%s", log_dir, filename);
index d89d6b16a59c49cf3ab2f20246b406879b0608e5..10b50a2d38165654edf0ea44bd37fd2fe29d5197 100644 (file)
@@ -1531,9 +1531,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
                 SCLogRedisInit();
                 json_ctx->json_out = LOGFILE_TYPE_REDIS;
 #else
-                SCLogError(SC_ERR_INVALID_ARGUMENT,
-                           "redis JSON output option is not compiled");
-                exit(EXIT_FAILURE);
+                           FatalError(SC_ERR_FATAL,
+                                      "redis JSON output option is not compiled");
 #endif
             } else {
                 SCLogError(SC_ERR_INVALID_ARGUMENT,
@@ -1549,9 +1548,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
             json_ctx->file_ctx->prefix = SCStrdup(prefix);
             if (json_ctx->file_ctx->prefix == NULL)
             {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                    "Failed to allocate memory for eve-log.prefix setting.");
-                exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to allocate memory for eve-log.prefix setting.");
             }
             json_ctx->file_ctx->prefix_len = strlen(prefix);
         }
index 504f176372e5e7200bbd72ddfd3ce89db2648c0b..6cd77dec39b27ae9a48e6a00bdb1b43a36bd811b 100644 (file)
@@ -857,10 +857,9 @@ error:
         SCLogDebug("ConfGetBool could not load the value.");
     }
     if (failure_fatal) {
-        SCLogError(SC_ERR_LUA_ERROR,
-                   "Error during setup of lua output. Details should be "
-                   "described in previous error messages. Shutting down...");
-        exit(EXIT_FAILURE);
+                   FatalError(SC_ERR_FATAL,
+                              "Error during setup of lua output. Details should be "
+                              "described in previous error messages. Shutting down...");
     }
 
     return result;
index 61b93d60978ad3e8573864015dd9a480f732307b..b091b751e8e2988bc527a36162a8d9453af3c383 100644 (file)
@@ -120,8 +120,7 @@ int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto,
         while (t->next)
             t = t->next;
         if (t->id * 2 > UINT32_MAX) {
-            SCLogError(SC_ERR_FATAL, "Too many loggers registered.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Too many loggers registered.");
         }
         op->id = t->id * 2;
         t->next = op;
index 7573bfda67e28b4ca235c53dba0eb4400d5c8bed..62547d8fd94218ebbaa1e8d13d7e5665bdd50381 100644 (file)
@@ -156,8 +156,8 @@ void OutputRegisterModule(const char *name, const char *conf_name,
     return;
 
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered in OutputRegisterModule. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL,
+               "Fatal error encountered in OutputRegisterModule. Exiting...");
 }
 
 /**
@@ -197,8 +197,7 @@ void OutputRegisterPacketModule(LoggerId id, const char *name,
     SCLogDebug("Packet logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -239,8 +238,7 @@ void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("Packet logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -284,8 +282,7 @@ static void OutputRegisterTxModuleWrapper(LoggerId id, const char *name,
     SCLogDebug("Tx logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name,
@@ -322,8 +319,7 @@ static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_nam
     SCLogDebug("Tx logger for alproto %d \"%s\" registered.", alproto, name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -453,8 +449,7 @@ void OutputRegisterFileModule(LoggerId id, const char *name,
     SCLogDebug("File logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -494,8 +489,7 @@ void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("File logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -534,8 +528,7 @@ void OutputRegisterFiledataModule(LoggerId id, const char *name,
     SCLogDebug("Filedata logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -575,8 +568,7 @@ void OutputRegisterFiledataSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("Filedata logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -614,8 +606,7 @@ void OutputRegisterFlowModule(LoggerId id, const char *name,
     SCLogDebug("Flow logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -655,8 +646,7 @@ void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("Flow logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -697,8 +687,7 @@ void OutputRegisterStreamingModule(LoggerId id, const char *name,
     SCLogDebug("Streaming logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -739,8 +728,7 @@ void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("Streaming logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -778,8 +766,7 @@ void OutputRegisterStatsModule(LoggerId id, const char *name,
     SCLogDebug("Stats logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
@@ -819,8 +806,7 @@ void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
     SCLogDebug("Stats logger \"%s\" registered.", name);
     return;
 error:
-    SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
 }
 
 /**
index fd24333fccd2c9bde36c48052aff913eac2301a3..36949b1a42438f5d86c7f5a77abda0cc1af520ad 100644 (file)
@@ -80,8 +80,7 @@ static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, int v
 {
     SReputation *user_data = NULL;
     if ((user_data = SCMalloc(sizeof(SReputation))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
     }
     memset(user_data, 0x00, sizeof(SReputation));
 
index 8143b43b00735aec4db72448f3dbc9003ba03f15..ee50e06ffe06485bf571fde47506b641bc320844 100644 (file)
@@ -815,8 +815,7 @@ int RunModeIdsAFPAutoFp(void)
     SCLogDebug("live_dev %s", live_dev);
 
     if (AFPPeersListInit() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to init peers list.");
     }
 
     ret = RunModeSetLiveCaptureAutoFp(ParseAFPConfig,
@@ -825,14 +824,12 @@ int RunModeIdsAFPAutoFp(void)
                               "DecodeAFP", thread_name_autofp,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     /* In IPS mode each threads must have a peer */
     if (AFPPeersListCheck() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
     }
 
     SCLogDebug("RunModeIdsAFPAutoFp initialised");
@@ -857,8 +854,7 @@ int RunModeIdsAFPSingle(void)
     (void)ConfGet("af-packet.live-interface", &live_dev);
 
     if (AFPPeersListInit() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to init peers list.");
     }
 
     ret = RunModeSetLiveCaptureSingle(ParseAFPConfig,
@@ -867,14 +863,12 @@ int RunModeIdsAFPSingle(void)
                                     "DecodeAFP", thread_name_single,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     /* In IPS mode each threads must have a peer */
     if (AFPPeersListCheck() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
     }
 
     SCLogDebug("RunModeIdsAFPSingle initialised");
@@ -902,8 +896,7 @@ int RunModeIdsAFPWorkers(void)
     (void)ConfGet("af-packet.live-interface", &live_dev);
 
     if (AFPPeersListInit() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to init peers list.");
     }
 
     ret = RunModeSetLiveCaptureWorkers(ParseAFPConfig,
@@ -912,14 +905,12 @@ int RunModeIdsAFPWorkers(void)
                                     "DecodeAFP", thread_name_workers,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     /* In IPS mode each threads must have a peer */
     if (AFPPeersListCheck() != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
     }
 
     SCLogDebug("RunModeIdsAFPWorkers initialised");
index f19709abb6d74849130a6a50ce45cec9978eb26f..3019f6caf917cdb56642c3069579fc3bf5a3a644 100644 (file)
@@ -84,8 +84,7 @@ int RunModeIdsErfDagSingle(void)
         thread_name_single,
         NULL);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "DAG single runmode failed to start");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "DAG single runmode failed to start");
     }
 
     SCLogInfo("RunModeIdsDagSingle initialised");
@@ -110,8 +109,7 @@ int RunModeIdsErfDagAutoFp(void)
         thread_name_autofp,
         NULL);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "DAG autofp runmode failed to start");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "DAG autofp runmode failed to start");
     }
 
     SCLogInfo("RunModeIdsDagAutoFp initialised");
@@ -136,8 +134,7 @@ int RunModeIdsErfDagWorkers(void)
         thread_name_workers,
         NULL);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "DAG workers runmode failed to start");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "DAG workers runmode failed to start");
     }
 
     SCLogInfo("RunModeIdsErfDagWorkers initialised");
index b3b97ea277d4b0ba8d52e78735e3c1c56831399e..27ef207606d1c30f752788dbbcc5dd8928e2a22d 100644 (file)
@@ -57,8 +57,7 @@ int RunModeErfFileSingle(void)
     SCEnter();
 
     if (ConfGet("erf-file.file", &file) == 0) {
-        SCLogError(SC_ERR_RUNMODE, "Failed to get erf-file.file from config.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to get erf-file.file from config.");
     }
 
     RunModeInitialize();
@@ -92,8 +91,7 @@ int RunModeErfFileSingle(void)
 
     tm_module = TmModuleGetByName("FlowWorker");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
     }
     TmSlotSetFuncAppend(tv, tm_module, NULL);
 
@@ -120,9 +118,8 @@ int RunModeErfFileAutoFp(void)
 
     const char *file = NULL;
     if (ConfGet("erf-file.file", &file) == 0) {
-        SCLogError(SC_ERR_RUNMODE,
-            "Failed retrieving erf-file.file from config");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Failed retrieving erf-file.file from config");
     }
 
     TimeModeSetOffline();
@@ -146,8 +143,8 @@ int RunModeErfFileAutoFp(void)
 
     queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
     if (queues == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "RunmodeAutoFpCreatePickupQueuesString failed");
     }
 
     /* create the threads */
@@ -207,8 +204,8 @@ int RunModeErfFileAutoFp(void)
 
         tm_module = TmModuleGetByName("FlowWorker");
         if (tm_module == NULL) {
-            SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "TmModuleGetByName for FlowWorker failed");
         }
         TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
 
index bb5fd617260c1c5156404cd55a5bebc4d7ee3b95..d7a206e064becd4e7dad8e395dc0632f06992186 100644 (file)
@@ -120,8 +120,8 @@ static int NapatechRegisterDeviceStreams(void)
      * automatically creates streams.  Therefore, these two options are mutually exclusive.
      */
     if (use_all_streams && auto_config) {
-        SCLogError(SC_ERR_RUNMODE, "napatech.auto-config cannot be used in configuration file at the same time as napatech.use-all-streams.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "napatech.auto-config cannot be used in configuration file at the same time as napatech.use-all-streams.");
     }
 
     /* to use hardware_bypass we need to configure the streams to be consistent.
@@ -129,8 +129,8 @@ static int NapatechRegisterDeviceStreams(void)
      * option.
      */
     if (use_hw_bypass && auto_config == 0) {
-        SCLogError(SC_ERR_RUNMODE, "napatech auto-config must be enabled when using napatech.use_hw_bypass.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "napatech auto-config must be enabled when using napatech.use_hw_bypass.");
     }
 
     /* Get the stream ID's either from the conf or by querying Napatech */
@@ -143,9 +143,8 @@ static int NapatechRegisterDeviceStreams(void)
     for (uint16_t inst = 0; inst < stream_cnt; ++inst) {
         char *plive_dev_buf = SCCalloc(1, 9);
         if (unlikely(plive_dev_buf == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-                    "Failed to allocate memory for NAPATECH stream counter.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to allocate memory for NAPATECH stream counter.");
         }
         snprintf(plive_dev_buf, 9, "nt%d", stream_config[inst].stream_id);
 
@@ -156,9 +155,8 @@ static int NapatechRegisterDeviceStreams(void)
                         plive_dev_buf);
                 SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
                         "run /opt/napatech3/bin/ntpl -e \"delete=all\" to delete existing stream");
-                SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
-                        "or disable auto-config in the conf file before running.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "or disable auto-config in the conf file before running.");
             }
         } else {
             SCLogInfo("Registering Napatech device: %s - active stream%sfound.",
@@ -234,16 +232,15 @@ static int NapatechInit(int runmode)
 
     status = NapatechRegisterDeviceStreams();
     if (status < 0 || num_configured_streams <= 0) {
-        SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
-                    "Unable to find existing Napatech Streams");
-        exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Unable to find existing Napatech Streams");
     }
 
     struct NapatechStreamDevConf *conf =
                             SCCalloc(1, sizeof (struct NapatechStreamDevConf));
     if (unlikely(conf == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH device.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Failed to allocate memory for NAPATECH device.");
     }
 
     if ((ConfGetInt("napatech.hba", &conf->hba) != 0) && (conf->hba > 0)) {
@@ -255,14 +252,12 @@ static int NapatechInit(int runmode)
         if (NapatechVerifyBypassSupport()) {
             SCLogInfo("Napatech Hardware Bypass is supported and enabled.");
         } else {
-            SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                    "Napatech Hardware Bypass requested in conf but is not supported by the hardware.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Napatech Hardware Bypass requested in conf but is not supported by the hardware.");
         }
 #else
-        SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
 #endif
     } else {
         SCLogInfo("Hardware Bypass is disabled in the conf file.");
@@ -283,8 +278,7 @@ static int NapatechInit(int runmode)
     }
 
     if (status != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
     return 0;
 }
index 0e1e9c157c6c3bb29a24feefd7a9fb4a8abeb9f4..12636934a1fad747cda7af22d8e7f35e046307f8 100644 (file)
@@ -423,8 +423,7 @@ int RunModeIdsNetmapAutoFp(void)
                               "DecodeNetmap", thread_name_autofp,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogDebug("RunModeIdsNetmapAutoFp initialised");
@@ -456,8 +455,7 @@ int RunModeIdsNetmapSingle(void)
                                     "DecodeNetmap", thread_name_single,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogDebug("RunModeIdsNetmapSingle initialised");
@@ -492,8 +490,7 @@ int RunModeIdsNetmapWorkers(void)
                                     "DecodeNetmap", thread_name_workers,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogDebug("RunModeIdsNetmapWorkers initialised");
index 569dcd78f749100ef2c56f8dbd5142907c71b396..56e242aed1467cd58a54f8451fe76f7c007c6525 100644 (file)
@@ -103,8 +103,7 @@ static void *ParseNflogConfig(const char *group)
     strlcpy(nflogconf->numgroup, group, sizeof(nflogconf->numgroup));
 
     if (ParseSizeStringU16(group, &nflogconf->group) < 0) {
-        SCLogError(SC_ERR_NFLOG_GROUP, "NFLOG's group number invalid.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "NFLOG's group number invalid.");
     }
 
     boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
@@ -185,8 +184,7 @@ int RunModeIdsNflogAutoFp(void)
                                       thread_name_autofp,
                                       live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogInfo("RunModeIdsNflogAutoFp initialised");
@@ -213,8 +211,7 @@ int RunModeIdsNflogSingle(void)
                                       thread_name_single,
                                       live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogInfo("RunModeIdsNflogSingle initialised");
@@ -241,8 +238,7 @@ int RunModeIdsNflogWorkers(void)
                                        thread_name_workers,
                                        live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogInfo("RunModeIdsNflogWorkers initialised");
index 7d0029dccbe5ce02f38bd40dd5c82fa097ca8306..371fef8dd9a085849226d688c1e2ff48c40d579c 100644 (file)
@@ -62,8 +62,7 @@ int RunModeFilePcapSingle(void)
     char tname[TM_THREAD_NAME_MAX];
 
     if (ConfGet("pcap-file.file", &file) == 0) {
-        SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
     }
 
     RunModeInitialize();
@@ -79,36 +78,31 @@ int RunModeFilePcapSingle(void)
                                                  "packetpool", "packetpool",
                                                  "pktacqloop");
     if (tv == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "threading setup failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "threading setup failed");
     }
 
     TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName failed for ReceivePcap");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
     }
     TmSlotSetFuncAppend(tv, tm_module, file);
 
     tm_module = TmModuleGetByName("DecodePcapFile");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName DecodePcap failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
     }
     TmSlotSetFuncAppend(tv, tm_module, NULL);
 
     tm_module = TmModuleGetByName("FlowWorker");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
     }
     TmSlotSetFuncAppend(tv, tm_module, NULL);
 
     TmThreadSetCPU(tv, WORKER_CPU_SET);
 
     if (TmThreadSpawn(tv) != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
     }
     return 0;
 }
@@ -141,8 +135,7 @@ int RunModeFilePcapAutoFp(void)
 
     const char *file = NULL;
     if (ConfGet("pcap-file.file", &file) == 0) {
-        SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
     }
     SCLogDebug("file %s", file);
 
@@ -169,8 +162,8 @@ int RunModeFilePcapAutoFp(void)
 
     queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
     if (queues == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "RunmodeAutoFpCreatePickupQueuesString failed");
     }
 
     snprintf(tname, sizeof(tname), "%s#01", thread_name_autofp);
@@ -184,28 +177,24 @@ int RunModeFilePcapAutoFp(void)
     SCFree(queues);
 
     if (tv_receivepcap == NULL) {
-        SCLogError(SC_ERR_FATAL, "threading setup failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "threading setup failed");
     }
     TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName failed for ReceivePcap");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
     }
     TmSlotSetFuncAppend(tv_receivepcap, tm_module, file);
 
     tm_module = TmModuleGetByName("DecodePcapFile");
     if (tm_module == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName DecodePcap failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
     }
     TmSlotSetFuncAppend(tv_receivepcap, tm_module, NULL);
 
     TmThreadSetCPU(tv_receivepcap, RECEIVE_CPU_SET);
 
     if (TmThreadSpawn(tv_receivepcap) != TM_ECODE_OK) {
-        SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
     }
 
     for (thread = 0; thread < (uint16_t)thread_max; thread++) {
@@ -221,14 +210,13 @@ int RunModeFilePcapAutoFp(void)
                                         "packetpool", "packetpool",
                                         "varslot");
         if (tv_detect_ncpu == NULL) {
-            SCLogError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
         }
 
         tm_module = TmModuleGetByName("FlowWorker");
         if (tm_module == NULL) {
-            SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "TmModuleGetByName for FlowWorker failed");
         }
         TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
 
@@ -237,8 +225,7 @@ int RunModeFilePcapAutoFp(void)
         TmThreadSetCPU(tv_detect_ncpu, WORKER_CPU_SET);
 
         if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
-            SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
         }
 
         if ((cpu + 1) == ncpus)
index 7cb35790f55c2a258e8ef83940cf123e9d9943e4..de451a78fa74dc91849efd015ebb7408bb2c7e2a 100644 (file)
@@ -251,8 +251,7 @@ int RunModeIdsPcapSingle(void)
                                     "DecodePcap", thread_name_single,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
 
     SCLogInfo("RunModeIdsPcapSingle initialised");
@@ -292,8 +291,7 @@ int RunModeIdsPcapAutoFp(void)
                               "DecodePcap", thread_name_autofp,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
 
     SCLogInfo("RunModeIdsPcapAutoFp initialised");
@@ -324,8 +322,7 @@ int RunModeIdsPcapWorkers(void)
                                     "DecodePcap", thread_name_workers,
                                     live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to start runmode");
     }
 
     SCLogInfo("RunModeIdsPcapWorkers initialised");
index 7359ba1df60baee1d0edcb020f6629f146f0de77..e0e52a5c8160bd9fe4bd13a49335ed1d7fd9ea5d 100644 (file)
@@ -470,9 +470,8 @@ int RunModeIdsPfringAutoFp(void)
 
     ret = GetDevAndParser(&live_dev, &tparser);
     if (ret != 0) {
-        SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
-                "Unable to get parser and interface params");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Unable to get parser and interface params");
     }
 
     ret = RunModeSetLiveCaptureAutoFp(tparser,
@@ -481,8 +480,7 @@ int RunModeIdsPfringAutoFp(void)
                               "DecodePfring", thread_name_autofp,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
 
     SCLogInfo("RunModeIdsPfringAutoFp initialised");
@@ -507,9 +505,8 @@ int RunModeIdsPfringSingle(void)
 
     ret = GetDevAndParser(&live_dev, &tparser);
     if (ret != 0) {
-        SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
-                "Unable to get parser and interface params");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Unable to get parser and interface params");
     }
 
     ret = RunModeSetLiveCaptureSingle(tparser,
@@ -518,8 +515,7 @@ int RunModeIdsPfringSingle(void)
                               "DecodePfring", thread_name_single,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
 
     SCLogInfo("RunModeIdsPfringSingle initialised");
@@ -544,9 +540,8 @@ int RunModeIdsPfringWorkers(void)
 
     ret = GetDevAndParser(&live_dev, &tparser);
     if (ret != 0) {
-        SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
-                "Unable to get parser and interface params");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Unable to get parser and interface params");
     }
 
     ret = RunModeSetLiveCaptureWorkers(tparser,
@@ -555,8 +550,7 @@ int RunModeIdsPfringWorkers(void)
                               "DecodePfring", thread_name_workers,
                               live_dev);
     if (ret != 0) {
-        SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Runmode start failed");
     }
 
     SCLogInfo("RunModeIdsPfringWorkers initialised");
index 60d5cf59cfacf04d3b24b2bae78d9a59fc46409d..4631d3189230e2a2e398b0599c3864a4d14cc873 100644 (file)
@@ -298,8 +298,7 @@ void RunUnittests(int list_unittests, const char *regex_arg)
 
     exit(EXIT_SUCCESS);
 #else
-    SCLogError(SC_ERR_NOT_SUPPORTED, "Unittests are not build-in");
-    exit(EXIT_FAILURE);
+    FatalError(SC_ERR_FATAL, "Unittests are not build-in");
 #endif /* UNITTESTS */
 }
 
index 1eaffec06b2720d49be9a8b7fce4060f3a1690aa..688a2496fcf88c1ee4e6724a960513438762e7fc 100644 (file)
@@ -334,8 +334,7 @@ void RunModeDispatch(int runmode, const char *custom_mode)
                 break;
 #endif
             default:
-                SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Unknown runtime mode. Aborting");
         }
     } else { /* if (custom_mode == NULL) */
         /* Add compability with old 'worker' name */
@@ -344,8 +343,7 @@ void RunModeDispatch(int runmode, const char *custom_mode)
                          "to 'workers', please modify your setup.");
             local_custom_mode = SCStrdup("workers");
             if (unlikely(local_custom_mode == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup custom mode");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Unable to dup custom mode");
             }
             custom_mode = local_custom_mode;
         }
@@ -366,8 +364,7 @@ void RunModeDispatch(int runmode, const char *custom_mode)
     }
     active_runmode = SCStrdup(custom_mode);
     if (unlikely(active_runmode == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup active mode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to dup active mode");
     }
 
     if (strcasecmp(active_runmode, "autofp") == 0) {
index 82f39f26b6f3db60cd72859670ff8d2179ff34d6..3ab39b7fe1614e1032df21e0c3de3bb867195f7e 100644 (file)
@@ -192,9 +192,8 @@ ReceiveErfDagThreadInit(ThreadVars *tv, void *initdata, void **data)
 
     ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
     if (unlikely(ewtn == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate memory for ERF DAG thread vars.");
-        exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Failed to allocate memory for ERF DAG thread vars.");
     }
 
     memset(ewtn, 0, sizeof(*ewtn));
index 3eab47a74f54a2e611eb11644a0939137f7bc2d2..9cc16f3ed856901fd509105909d1c1a18e57e347 100644 (file)
@@ -652,8 +652,8 @@ TmEcode NapatechStreamThreadInit(ThreadVars *tv, const void *initdata, void **da
 
     NapatechThreadVars *ntv = SCCalloc(1, sizeof (NapatechThreadVars));
     if (unlikely(ntv == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH  thread vars.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Failed to allocate memory for NAPATECH  thread vars.");
     }
 
     memset(ntv, 0, sizeof (NapatechThreadVars));
@@ -874,9 +874,8 @@ TmEcode NapatechPacketLoop(ThreadVars *tv, void *data, void *slot)
                 exit(EXIT_FAILURE);
 
             } else if (status == 0x20000008) {
-                SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
-                        "Check napatech.ports in the suricata config file.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Check napatech.ports in the suricata config file.");
             }
             RecommendNUMAConfig(SC_LOG_PERF);
             SCLogNotice("Napatech packet input engine started.");
@@ -890,9 +889,8 @@ TmEcode NapatechPacketLoop(ThreadVars *tv, void *data, void *slot)
     if (ntv->hba > 0) {
         char *s_hbad_pkt = SCCalloc(1, 32);
         if (unlikely(s_hbad_pkt == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-                    "Failed to allocate memory for NAPATECH stream counter.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to allocate memory for NAPATECH stream counter.");
         }
         snprintf(s_hbad_pkt, 32, "nt%d.hba_drop", ntv->stream_id);
         hba_pkt = StatsRegisterCounter(s_hbad_pkt, tv);
index 10f3b826b1e7667c7efa465cf7d85e6835903889..74fafdf67db192a536dad68b0b2179d180fad930 100644 (file)
@@ -242,12 +242,10 @@ TmEcode ReceiveNFLOGThreadInit(ThreadVars *tv, const void *initdata, void **data
     SCLogDebug("binding netfilter_log as nflog handler for AF_INET and AF_INET6");
 
     if (nflog_bind_pf(ntv->h, AF_INET) < 0) {
-        SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET failed");
     }
     if (nflog_bind_pf(ntv->h, AF_INET6) < 0) {
-        SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET6 failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET6 failed");
     }
 
     ntv->gh = nflog_bind_group(ntv->h, ntv->group);
@@ -348,13 +346,11 @@ TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *tv, void *data)
 
     SCLogDebug("closing nflog group %d", ntv->group);
     if (nflog_unbind_pf(ntv->h, AF_INET) < 0) {
-        SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET failed");
     }
 
     if (nflog_unbind_pf(ntv->h, AF_INET6) < 0) {
-        SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET6 failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET6 failed");
     }
 
     if (ntv->gh) {
index fbfbf371d953d42bfc8df2b5de148e1f85b1b993..6a42cfde267a336a602ac23e1b88d2c5b298fdf4 100644 (file)
@@ -226,8 +226,7 @@ void NFQInitConfig(char quiet)
         }  else if (!strcmp("route", nfq_mode)) {
             nfq_config.mode = NFQ_ROUTE_MODE;
         } else {
-            SCLogError(SC_ERR_INVALID_ARGUMENT, "Unknown nfq.mode");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Unknown nfq.mode");
         }
     }
 
@@ -591,24 +590,20 @@ static TmEcode NFQInitThread(NFQThreadVars *t, uint32_t queue_maxlen)
          * 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(q->h, AF_INET) < 0) {
-            SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "nfq_unbind_pf() for AF_INET failed");
         }
         if (nfq_unbind_pf(q->h, AF_INET6) < 0) {
-            SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "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(q->h, AF_INET) < 0) {
-            SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET failed");
         }
         if (nfq_bind_pf(q->h, AF_INET6) < 0) {
-            SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET6 failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET6 failed");
         }
     }
 
index 10cc5ccc014cd0009564f32c578c44a7224bc565..bfa5f54951d3005e99db259a79082c89d49272bb 100644 (file)
@@ -569,10 +569,9 @@ void StreamTcpInitConfig(char quiet)
                         temp_rdrange);
                 exit(EXIT_FAILURE);
             } else if (rdrange >= 100) {
-                SCLogError(SC_ERR_INVALID_VALUE,
-                           "stream.reassembly.randomize-chunk-range "
-                           "must be lower than 100");
-                exit(EXIT_FAILURE);
+                           FatalError(SC_ERR_FATAL,
+                                      "stream.reassembly.randomize-chunk-range "
+                                      "must be lower than 100");
             }
         }
     }
index 09c3ba3f90a5e014c9eac41a0fe7bbca8c622a4f..74cbccef12036fa0d08794de066fcb6275e1746c 100644 (file)
@@ -467,10 +467,9 @@ static void SetBpfStringFromFile(char *filename)
     size_t nm = 0;
 
     if (EngineModeIsIPS()) {
-        SCLogError(SC_ERR_NOT_SUPPORTED,
-                   "BPF filter not available in IPS mode."
-                   " Use firewall filtering if possible.");
-        exit(EXIT_FAILURE);
+                   FatalError(SC_ERR_FATAL,
+                              "BPF filter not available in IPS mode."
+                              " Use firewall filtering if possible.");
     }
 
 #ifdef OS_WIN32
@@ -1549,9 +1548,8 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
                     /* Quick validation. */
                     char *val = strchr(optarg, '=');
                     if (val == NULL) {
-                        SCLogError(SC_ERR_CMD_LINE,
-                                "Invalid argument for --set, must be key=val.");
-                        exit(EXIT_FAILURE);
+                                FatalError(SC_ERR_FATAL,
+                                           "Invalid argument for --set, must be key=val.");
                     }
                     if (!ConfSetFromString(optarg, 1)) {
                         fprintf(stderr, "Failed to set configuration value %s.",
@@ -2315,9 +2313,8 @@ void PostConfLoadedDetectSetup(SCInstance *suri)
         if (mt_enabled)
             (void)ConfGetBool("multi-detect.default", &default_tenant);
         if (DetectEngineMultiTenantSetup() == -1) {
-            SCLogError(SC_ERR_INITIALIZATION, "initializing multi-detect "
-                    "detection engine contexts failed.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "initializing multi-detect "
+                       "detection engine contexts failed.");
         }
         if (suri->delayed_detect && suri->run_mode != RUNMODE_CONF_TEST) {
             de_ctx = DetectEngineCtxInitStubForDD();
@@ -2327,9 +2324,8 @@ void PostConfLoadedDetectSetup(SCInstance *suri)
             de_ctx = DetectEngineCtxInit();
         }
         if (de_ctx == NULL) {
-            SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
-                    "context failed.");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "initializing detection engine "
+                       "context failed.");
         }
 
         if (de_ctx->type == DETECT_ENGINE_TYPE_NORMAL) {
@@ -2788,9 +2784,8 @@ int SuricataMain(int argc, char **argv)
 
     /* Wait till all the threads have been initialized */
     if (TmThreadWaitOnThreadInit() == TM_ECODE_FAILED) {
-        SCLogError(SC_ERR_INITIALIZATION, "Engine initialization failed, "
+        FatalError(SC_ERR_FATAL, "Engine initialization failed, "
                    "aborting...");
-        exit(EXIT_FAILURE);
     }
 
     SC_ATOMIC_SET(engine_stage, SURICATA_RUNTIME);
index 562c41e12461baa139c816c9d7075f4358664c2a..549af74baa121251b4a386a7bdeee16c1ea734ae 100644 (file)
@@ -1663,9 +1663,9 @@ TmEcode TmThreadSpawn(ThreadVars *tv)
 void TmThreadInitMC(ThreadVars *tv)
 {
     if ( (tv->ctrl_mutex = SCMalloc(sizeof(*tv->ctrl_mutex))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in TmThreadInitMC.  "
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in TmThreadInitMC.  "
                    "Exiting...");
-        exit(EXIT_FAILURE);
     }
 
     if (SCCtrlMutexInit(tv->ctrl_mutex, NULL) != 0) {
@@ -1674,15 +1674,14 @@ void TmThreadInitMC(ThreadVars *tv)
     }
 
     if ( (tv->ctrl_cond = SCMalloc(sizeof(*tv->ctrl_cond))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in TmThreadInitMC.  "
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in TmThreadInitMC.  "
                    "Exiting...");
-        exit(EXIT_FAILURE);
     }
 
     if (SCCtrlCondInit(tv->ctrl_cond, NULL) != 0) {
-        SCLogError(SC_ERR_FATAL, "Error initializing the tv->cond condition "
+        FatalError(SC_ERR_FATAL, "Error initializing the tv->cond condition "
                    "variable");
-        exit(EXIT_FAILURE);
     }
 
     return;
index ead8d0106ac5d1af8d65315f8405d3de274a2824..db93d45b7e46bc511d291a4ea234846606cb64b4 100644 (file)
@@ -322,8 +322,8 @@ void PacketPoolInit(void)
     for (i = 0; i < max_pending_packets; i++) {
         Packet *p = PacketGetFromAlloc();
         if (unlikely(p == NULL)) {
-            SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Fatal error encountered while allocating a packet. Exiting...");
         }
         PacketPoolStorePacket(p);
     }
index bfa394b7a6736f3e0e1aca0533c2acf55b19b4db..4661bb14f9c505d6de6b05983e6585662729e627 100644 (file)
@@ -1043,9 +1043,8 @@ int UnixManagerInit(void)
             SCLogDebug("ConfGetBool could not load the value.");
         }
         if (failure_fatal) {
-            SCLogError(SC_ERR_INITIALIZATION,
-                    "Unable to create unix command socket");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Unable to create unix command socket");
         } else {
             SCLogWarning(SC_ERR_INITIALIZATION,
                     "Unable to create unix command socket");
@@ -1160,17 +1159,14 @@ void UnixManagerThreadSpawn(int mode)
                                           "UnixManager", 0);
 
     if (tv_unixmgr == NULL) {
-        SCLogError(SC_ERR_INITIALIZATION, "TmThreadsCreate failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
     }
     if (TmThreadSpawn(tv_unixmgr) != TM_ECODE_OK) {
-        SCLogError(SC_ERR_INITIALIZATION, "TmThreadSpawn failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
     }
     if (mode == 1) {
         if (TmThreadsCheckFlag(tv_unixmgr, THV_RUNNING_DONE)) {
-            SCLogError(SC_ERR_INITIALIZATION, "Unix socket init failed");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Unix socket init failed");
         }
     }
     return;
index 0fcafa0d040d6a033837096e5d358381bf77a55a..3a9c8f08a1fea2b493bb77507f86f936016f5afc 100644 (file)
@@ -211,8 +211,7 @@ void AffinitySetupLoadFromConfig()
         ConfNode *nprio = NULL;
 
         if (taf == NULL) {
-            SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu-affinity type");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "unknown cpu-affinity type");
         } else {
             SCLogConfig("Found affinity definition for \"%s\"", setname);
         }
@@ -259,8 +258,7 @@ void AffinitySetupLoadFromConfig()
                 } else if (!strcmp(node->val, "high")) {
                     taf->prio = PRIO_HIGH;
                 } else {
-                    SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu_affinity prio");
-                    exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL, "unknown cpu_affinity prio");
                 }
                 SCLogConfig("Using default prio '%s' for set '%s'",
                         node->val, setname);
@@ -274,8 +272,7 @@ void AffinitySetupLoadFromConfig()
             } else if (!strcmp(node->val, "balanced")) {
                 taf->mode_flag = BALANCED_AFFINITY;
             } else {
-                SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu_affinity node");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "unknown cpu_affinity node");
             }
         }
 
@@ -286,8 +283,7 @@ void AffinitySetupLoadFromConfig()
                            "count: '%s'", node->val);
             }
             if (! taf->nb_threads) {
-                SCLogError(SC_ERR_INVALID_ARGUMENT, "bad value for threads count");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "bad value for threads count");
             }
         }
     }
index ee2d625a00e996ea21d4f9e252d439a0d9d8abee..8e6e6b63cda594be8518994b1f6200fa9c8266fb 100644 (file)
@@ -70,8 +70,7 @@ static void WaitForChild (pid_t pid)
         if (waitpid(pid, &status, WNOHANG)) {
             /* Check if the child is still there, otherwise the parent should exit */
             if (WIFEXITED(status) || WIFSIGNALED(status)) {
-                SCLogError(SC_ERR_DAEMON, "Child died unexpectedly");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Child died unexpectedly");
             }
         }
         /* sigsuspend(); */
@@ -115,22 +114,20 @@ void Daemonize (void)
 
     if (pid < 0) {
         /* Fork error */
-        SCLogError(SC_ERR_DAEMON, "Error forking the process");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error forking the process");
     } else if (pid == 0) {
         /* Child continues here */
         const char *daemondir;
 
         sid = setsid();
         if (sid < 0) {
-            SCLogError(SC_ERR_DAEMON, "Error creating new session");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error creating new session");
         }
 
         if (ConfGet("daemon-directory", &daemondir) == 1) {
             if ((chdir(daemondir)) < 0) {
-                SCLogError(SC_ERR_DAEMON, "Error changing to working directory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Error changing to working directory");
             }
         }
 #ifndef OS_WIN32
index bba36559a323d78707dacc9a71f536ea5a2d363b..a94db699a5d21b017f52a3bf97c27cff356d510b 100644 (file)
@@ -862,8 +862,8 @@ void SCLogAddToFGFFileList(SCLogFGFilterFile *fgf_file,
     SCLogFGFilterLine *fgf_line_temp = NULL;
 
     if ( (fgf_file_temp = SCMalloc(sizeof(SCLogFGFilterFile))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
     }
     memset(fgf_file_temp, 0, sizeof(SCLogFGFilterFile));
 
@@ -873,8 +873,8 @@ void SCLogAddToFGFFileList(SCLogFGFilterFile *fgf_file,
     }
 
     if ( (fgf_func_temp = SCMalloc(sizeof(SCLogFGFilterFunc))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
     }
     memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
 
@@ -884,8 +884,8 @@ void SCLogAddToFGFFileList(SCLogFGFilterFile *fgf_file,
     }
 
     if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
     }
     memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
 
@@ -926,8 +926,8 @@ void SCLogAddToFGFFuncList(SCLogFGFilterFile *fgf_file,
     SCLogFGFilterLine *fgf_line_temp = NULL;
 
     if ( (fgf_func_temp = SCMalloc(sizeof(SCLogFGFilterFunc))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
     }
     memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
 
@@ -937,8 +937,8 @@ void SCLogAddToFGFFuncList(SCLogFGFilterFile *fgf_file,
     }
 
     if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
     }
     memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
 
@@ -975,8 +975,8 @@ void SCLogAddToFGFLineList(SCLogFGFilterFunc *fgf_func,
     SCLogFGFilterLine *fgf_line_temp = NULL;
 
     if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
     }
     memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
 
index c4575cac66e9efc27c98bbd12fbf90e21ea5c91f..6a808bfe5bd9c4b6eff0e1041d36384cb787d718 100644 (file)
@@ -686,8 +686,8 @@ SCLogOPBuffer *SCLogAllocLogOPBuffer(void)
 
     if ( (buffer = SCMalloc(sc_log_config->op_ifaces_cnt *
                           sizeof(SCLogOPBuffer))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
     }
 
     op_iface_ctx = sc_log_config->op_ifaces;
@@ -714,8 +714,8 @@ static inline SCLogOPIfaceCtx *SCLogAllocLogOPIfaceCtx(void)
     SCLogOPIfaceCtx *iface_ctx = NULL;
 
     if ( (iface_ctx = SCMalloc(sizeof(SCLogOPIfaceCtx))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
     }
     memset(iface_ctx, 0, sizeof(SCLogOPIfaceCtx));
 
@@ -741,8 +741,8 @@ static inline SCLogOPIfaceCtx *SCLogInitFileOPIface(const char *file,
     SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
 
     if (iface_ctx == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitFileOPIface. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogInitFileOPIface. Exiting...");
     }
 
     if (file == NULL) {
@@ -806,8 +806,8 @@ static inline SCLogOPIfaceCtx *SCLogInitConsoleOPIface(const char *log_format,
     SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
 
     if (iface_ctx == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
     }
 
     iface_ctx->iface = SC_LOG_OP_IFACE_CONSOLE;
@@ -872,8 +872,8 @@ static inline SCLogOPIfaceCtx *SCLogInitSyslogOPIface(int facility,
     SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
 
     if ( iface_ctx == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitSyslogOPIface. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogInitSyslogOPIface. Exiting...");
     }
 
     iface_ctx->iface = SC_LOG_OP_IFACE_SYSLOG;
@@ -1304,15 +1304,14 @@ void SCLogInitLogModule(SCLogInitData *sc_lid)
 
 #if defined (OS_WIN32)
     if (SCMutexInit(&sc_log_stream_lock, NULL) != 0) {
-        SCLogError(SC_ERR_MUTEX, "Failed to initialize log mutex.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to initialize log mutex.");
     }
 #endif /* OS_WIN32 */
 
     /* sc_log_config is a global variable */
     if ( (sc_log_config = SCMalloc(sizeof(SCLogConfig))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitLogModule. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCLogInitLogModule. Exiting...");
     }
     memset(sc_log_config, 0, sizeof(SCLogConfig));
 
@@ -1429,9 +1428,8 @@ void SCLogLoadConfig(int daemon, int verbose)
         else if (strcmp(output->name, "file") == 0) {
             const char *filename = ConfNodeLookupChildValue(output, "filename");
             if (filename == NULL) {
-                SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
-                    "Logging to file requires a filename");
-                exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Logging to file requires a filename");
             }
             char *path = NULL;
             if (!(PathIsAbsolute(filename))) {
index 55b06ea70c752dce278f4369f1472b5fb4860bf9..97c52c0ad381ad5287b663541723117635b022d5 100644 (file)
@@ -78,8 +78,7 @@ static void *SCHInfoAllocUserDataOSPolicy(const char *host_os)
     int *user_data = NULL;
 
     if ( (user_data = SCMalloc(sizeof(int))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
     }
 
     /* the host os flavour that has to be sent as user data */
@@ -157,8 +156,7 @@ int SCHInfoAddHostOSInfo(const char *host_os, const char *host_os_ip_range, int
     }
 
     if ( (ip_str = SCStrdup(host_os_ip_range)) == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
 
     /* check if we have more addresses in the host_os_ip_range */
index 293e55527b4ad49aac48af9b1aa361c9b6569237..aad49df0e18f29b71796f3476df627f2e6737003 100644 (file)
@@ -134,8 +134,8 @@ struct in_addr *ValidateIPV4Address(const char *addr_str)
         return NULL;
 
     if ( (addr = SCMalloc(sizeof(struct in_addr))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in ValidateIPV4Address. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in ValidateIPV4Address. Exiting...");
     }
 
     if (inet_pton(AF_INET, addr_str, addr) <= 0) {
@@ -164,8 +164,8 @@ struct in6_addr *ValidateIPV6Address(const char *addr_str)
         return NULL;
 
     if ( (addr = SCMalloc(sizeof(struct in6_addr))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in ValidateIPV6Address. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in ValidateIPV6Address. Exiting...");
     }
 
     if (inet_pton(AF_INET6, addr_str, addr) <= 0) {
index 2dc1d86943015b21948d48d00708f96e08fe0035..4f437f02ba6458dc9cf469416a537f53d003c7e0 100644 (file)
@@ -59,8 +59,7 @@ static SCLogRedisContext *SCLogRedisContextAlloc(void)
 {
     SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
     if (ctx == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis context");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
     }
     ctx->sync = NULL;
 #if HAVE_LIBEVENT
@@ -85,8 +84,7 @@ static SCLogRedisContext *SCLogRedisContextAsyncAlloc(void)
 {
     SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
     if (unlikely(ctx == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis context");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
     }
 
     ctx->sync = NULL;
@@ -526,14 +524,12 @@ int SCConfLogOpenRedis(ConfNode *redis_node, void *lf_ctx)
     } else if(!strcmp(redis_mode,"channel") || !strcmp(redis_mode,"publish")) {
         log_ctx->redis_setup.command = redis_publish_cmd;
     } else {
-        SCLogError(SC_ERR_REDIS_CONFIG,"Invalid redis mode");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Invalid redis mode");
     }
 
     /* store server params for reconnection */
     if (!log_ctx->redis_setup.server) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating redis server string");
-        exit(EXIT_FAILURE);
+        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);
index 956aabb7d3ebf085be69b02bcc479d69464cce60..40eecbf2b87ae43ab505dbcb1258abc8ef34bc79 100644 (file)
@@ -361,9 +361,8 @@ SCConfLogOpenGeneric(ConfNode *conf,
         else {
             log_ctx->rotate_interval = SCParseTimeSizeString(rotate_int);
             if (log_ctx->rotate_interval == 0) {
-                SCLogError(SC_ERR_INVALID_NUMERIC_VALUE,
-                           "invalid rotate-interval value");
-                exit(EXIT_FAILURE);
+                           FatalError(SC_ERR_FATAL,
+                                      "invalid rotate-interval value");
             }
             log_ctx->rotate_time = now + log_ctx->rotate_interval;
         }
index 6f0a656d4a217ef7fa4e73ff595c26324a788ac9..2a56aa104669db4168d160c959a85c9be21f1455 100644 (file)
@@ -147,8 +147,7 @@ static inline int SCACBSInitNewState(MpmCtx *mpm_ctx)
     if (ptmp == NULL) {
         SCFree(ctx->goto_table);
         ctx->goto_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->goto_table = ptmp;
 
@@ -163,8 +162,7 @@ static inline int SCACBSInitNewState(MpmCtx *mpm_ctx)
     if (ptmp == NULL) {
         SCFree(ctx->output_table);
         ctx->output_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->output_table = ptmp;
 
@@ -206,8 +204,7 @@ static void SCACBSSetOutputState(int32_t state, uint32_t pid, MpmCtx *mpm_ctx)
     if (ptmp == NULL) {
         SCFree(output_state->pids);
         output_state->pids = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     output_state->pids = ptmp;
 
@@ -399,8 +396,7 @@ static inline void SCACBSClubOutputStates(int32_t dst_state, int32_t src_state,
             if (ptmp == NULL) {
                 SCFree(output_dst_state->pids);
                 output_dst_state->pids = NULL;
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Error allocating memory");
             }
             else {
                 output_dst_state->pids = ptmp;
@@ -434,8 +430,7 @@ static inline void SCACBSCreateFailureTable(MpmCtx *mpm_ctx)
      * every state(SCACBSCtx->state_count) */
     ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
     if (ctx->failure_table == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
 
@@ -487,8 +482,7 @@ static inline void SCACBSCreateDeltaTable(MpmCtx *mpm_ctx)
         ctx->state_table_u16 = SCMalloc(ctx->state_count *
                                         sizeof(SC_AC_BS_STATE_TYPE_U16) * 256);
         if (ctx->state_table_u16 == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_u16, 0,
                ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U16) * 256);
@@ -528,8 +522,7 @@ static inline void SCACBSCreateDeltaTable(MpmCtx *mpm_ctx)
         ctx->state_table_u32 = SCMalloc(ctx->state_count *
                                         sizeof(SC_AC_BS_STATE_TYPE_U32) * 256);
         if (ctx->state_table_u32 == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_u32, 0,
                ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U32) * 256);
@@ -697,8 +690,7 @@ static inline void SCACBSCreateModDeltaTable(MpmCtx *mpm_ctx)
                  256 * sizeof(SC_AC_BS_STATE_TYPE_U16) * 1);
         ctx->state_table_mod = SCMalloc(size);
         if (ctx->state_table_mod == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_mod, 0, size);
 
@@ -709,8 +701,7 @@ static inline void SCACBSCreateModDeltaTable(MpmCtx *mpm_ctx)
          * directly to access its state data */
         ctx->state_table_mod_pointers = SCMalloc(ctx->state_count * sizeof(uint8_t *));
         if (ctx->state_table_mod_pointers == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_mod_pointers, 0,
                ctx->state_count * sizeof(uint8_t *));
@@ -771,8 +762,7 @@ static inline void SCACBSCreateModDeltaTable(MpmCtx *mpm_ctx)
                  256 * sizeof(SC_AC_BS_STATE_TYPE_U32) * 1);
         ctx->state_table_mod = SCMalloc(size);
         if (ctx->state_table_mod == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_mod, 0, size);
 
@@ -783,8 +773,7 @@ static inline void SCACBSCreateModDeltaTable(MpmCtx *mpm_ctx)
          * directly to access its state data */
         ctx->state_table_mod_pointers = SCMalloc(ctx->state_count * sizeof(uint8_t *));
         if (ctx->state_table_mod_pointers == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_mod_pointers, 0,
                ctx->state_count * sizeof(uint8_t *));
@@ -925,8 +914,7 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx)
     /* handle no case patterns */
     ctx->pid_pat_list = SCMalloc((mpm_ctx->max_pat_id + 1)* sizeof(SCACBSPatternList));
     if (ctx->pid_pat_list == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(ctx->pid_pat_list, 0, (mpm_ctx->max_pat_id + 1) * sizeof(SCACBSPatternList));
 
@@ -934,8 +922,7 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx)
         if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
             ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
             if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Error allocating memory");
             }
             memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
                    ctx->parray[i]->original_pat, ctx->parray[i]->len);
index cb521decd293de44e841d03dbc542af012d33bf7..deb574f0aabaa8f3f7ae944fc8337e23025b2949 100644 (file)
@@ -235,8 +235,7 @@ static void SCACTileReallocOutputTable(SCACTileCtx *ctx, int new_state_count)
     if (ptmp == NULL) {
         SCFree(ctx->output_table);
         ctx->output_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->output_table = ptmp;
 }
@@ -249,8 +248,7 @@ static void SCACTileReallocState(SCACTileCtx *ctx, int new_state_count)
     if (ptmp == NULL) {
         SCFree(ctx->goto_table);
         ctx->goto_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->goto_table = ptmp;
 
@@ -323,8 +321,7 @@ static void SCACTileSetOutputState(int32_t state, MpmPatternIndex pindex, MpmCtx
     if (ptmp == NULL) {
         SCFree(output_state->patterns);
         output_state->patterns = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     output_state->patterns = ptmp;
 
@@ -484,8 +481,7 @@ static void SCACTileClubOutputStates(int32_t dst_state,
             if (ptmp == NULL) {
                 SCFree(output_dst_state->patterns);
                 output_dst_state->patterns = NULL;
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Error allocating memory");
             }
             output_dst_state->patterns = ptmp;
 
@@ -517,8 +513,7 @@ static void SCACTileCreateFailureTable(MpmCtx *mpm_ctx)
      * every state(SCACTileCtx->state_count) */
     ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
     if (ctx->failure_table == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
 
@@ -562,8 +557,7 @@ static void SCACTileSetState1Byte(SCACTileCtx *ctx, int state, int aa,
     uint8_t encoded_next_state = next_state;
 
     if (next_state == SC_AC_TILE_FAIL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error FAIL state in output");
     }
 
     if (outputs == 0)
@@ -582,8 +576,7 @@ static void SCACTileSetState2Bytes(SCACTileCtx *ctx, int state, int aa,
     uint16_t encoded_next_state = next_state;
 
     if (next_state == SC_AC_TILE_FAIL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error FAIL state in output");
     }
 
     if (outputs == 0)
@@ -602,8 +595,7 @@ static void SCACTileSetState4Bytes(SCACTileCtx *ctx, int state, int aa,
     uint32_t encoded_next_state = next_state;
 
     if (next_state == SC_AC_TILE_FAIL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error FAIL state in output");
     }
 
     if (outputs == 0)
@@ -720,8 +712,7 @@ static void SCACTileClubOutputStatePresenceWithDeltaTable(MpmCtx *mpm_ctx)
     int size = ctx->state_count * ctx->bytes_per_state * ctx->alphabet_storage;
     void *state_table = SCMalloc(size);
     if (unlikely(state_table == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(state_table, 0, size);
     ctx->state_table = state_table;
@@ -927,8 +918,7 @@ int SCACTilePreparePatterns(MpmCtx *mpm_ctx)
     size_t mem_size = string_space_needed + pattern_list_size;
     void *mem_block = SCCalloc(1, mem_size);
     if (mem_block == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     mpm_ctx->memory_cnt++;
     mpm_ctx->memory_size += mem_size;
index e972cb6f4ea77ef10e29579800569e16c41049e1..62415321a0e15134ac776c7e03cc4e85fe971704 100644 (file)
@@ -153,8 +153,7 @@ static inline int SCACReallocState(SCACCtx *ctx, uint32_t cnt)
     if (ptmp == NULL) {
         SCFree(ctx->goto_table);
         ctx->goto_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->goto_table = ptmp;
 
@@ -171,8 +170,7 @@ static inline int SCACReallocState(SCACCtx *ctx, uint32_t cnt)
     if (ptmp == NULL) {
         SCFree(ctx->output_table);
         ctx->output_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->output_table = ptmp;
 
@@ -210,8 +208,7 @@ static void SCACShrinkState(SCACCtx *ctx)
     if (ptmp == NULL) {
         SCFree(ctx->output_table);
         ctx->output_table = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     ctx->output_table = ptmp;
 }
@@ -271,8 +268,7 @@ static void SCACSetOutputState(int32_t state, uint32_t pid, MpmCtx *mpm_ctx)
     if (ptmp == NULL) {
         SCFree(output_state->pids);
         output_state->pids = NULL;
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     output_state->pids = ptmp;
 
@@ -485,8 +481,7 @@ static inline void SCACClubOutputStates(int32_t dst_state, int32_t src_state,
             if (ptmp == NULL) {
                 SCFree(output_dst_state->pids);
                 output_dst_state->pids = NULL;
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Error allocating memory");
             }
             output_dst_state->pids = ptmp;
 
@@ -518,8 +513,7 @@ static inline void SCACCreateFailureTable(MpmCtx *mpm_ctx)
      * every state(SCACCtx->state_count) */
     ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
     if (ctx->failure_table == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
 
@@ -571,8 +565,7 @@ static inline void SCACCreateDeltaTable(MpmCtx *mpm_ctx)
         ctx->state_table_u16 = SCMalloc(ctx->state_count *
                                         sizeof(SC_AC_STATE_TYPE_U16) * 256);
         if (ctx->state_table_u16 == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_u16, 0,
                ctx->state_count * sizeof(SC_AC_STATE_TYPE_U16) * 256);
@@ -614,8 +607,7 @@ static inline void SCACCreateDeltaTable(MpmCtx *mpm_ctx)
         ctx->state_table_u32 = SCMalloc(ctx->state_count *
                                         sizeof(SC_AC_STATE_TYPE_U32) * 256);
         if (ctx->state_table_u32 == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(ctx->state_table_u32, 0,
                ctx->state_count * sizeof(SC_AC_STATE_TYPE_U32) * 256);
@@ -811,8 +803,7 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx)
     /* handle no case patterns */
     ctx->pid_pat_list = SCMalloc((mpm_ctx->max_pat_id + 1)* sizeof(SCACPatternList));
     if (ctx->pid_pat_list == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Error allocating memory");
     }
     memset(ctx->pid_pat_list, 0, (mpm_ctx->max_pat_id + 1) * sizeof(SCACPatternList));
 
@@ -820,8 +811,7 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx)
         if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
             ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
             if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "Error allocating memory");
             }
             memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
                    ctx->parray[i]->original_pat, ctx->parray[i]->len);
index 194a7bbd783c1b786cbce5f1d17dbb12d9d1f7e2..9ad204456f96de2895b28bbcf9533252bcd832af 100644 (file)
@@ -107,8 +107,7 @@ static void SCHSSetAllocators(void)
 {
     hs_error_t err = hs_set_allocator(SCHSMalloc, SCHSFree);
     if (err != HS_SUCCESS) {
-        SCLogError(SC_ERR_FATAL, "Failed to set Hyperscan allocator.");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed to set Hyperscan allocator.");
     }
 }
 
@@ -784,14 +783,12 @@ void SCHSInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
     SCMutexUnlock(&g_scratch_proto_mutex);
 
     if (err != HS_SUCCESS) {
-        SCLogError(SC_ERR_FATAL, "Unable to clone scratch prototype");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to clone scratch prototype");
     }
 
     err = hs_scratch_size(ctx->scratch, &ctx->scratch_size);
     if (err != HS_SUCCESS) {
-        SCLogError(SC_ERR_FATAL, "Unable to query scratch size");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Unable to query scratch size");
     }
 
     mpm_thread_ctx->memory_cnt++;
index f7d0b1f46c44615e023ce237f8afc886e185e3c3..fb7a3818f5b1f59e745e2769733811a0889a86d2 100644 (file)
@@ -62,15 +62,13 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
     if (de_ctx->mpm_ctx_factory_container == NULL) {
         de_ctx->mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer));
         if (de_ctx->mpm_ctx_factory_container == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
 
         MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
         if (unlikely(item == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
 
         item[0].name = name;
@@ -78,8 +76,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         /* toserver */
         item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
         if (item[0].mpm_ctx_ts == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
         item[0].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -87,8 +84,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         /* toclient */
         item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
         if (item[0].mpm_ctx_tc == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
         item[0].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -112,8 +108,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
                 if (items[i].mpm_ctx_ts == NULL) {
                     items[i].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
                     if (items[i].mpm_ctx_ts == NULL) {
-                        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                        exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL, "Error allocating memory");
                     }
                     memset(items[i].mpm_ctx_ts, 0, sizeof(MpmCtx));
                     items[i].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -121,8 +116,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
                 if (items[i].mpm_ctx_tc == NULL) {
                     items[i].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
                     if (items[i].mpm_ctx_tc == NULL) {
-                        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-                        exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL, "Error allocating memory");
                     }
                     memset(items[i].mpm_ctx_tc, 0, sizeof(MpmCtx));
                     items[i].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -137,8 +131,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         if (unlikely(ptmp == NULL)) {
             SCFree(items);
             items = NULL;
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         items = ptmp;
 
@@ -150,8 +143,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         /* toserver */
         new_item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
         if (new_item[0].mpm_ctx_ts == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(new_item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
         new_item[0].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -159,8 +151,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
         /* toclient */
         new_item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
         if (new_item[0].mpm_ctx_tc == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(new_item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
         new_item[0].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
@@ -197,8 +188,7 @@ MpmCtx *MpmFactoryGetMpmCtxForProfile(const DetectEngineCtx *de_ctx, int32_t id,
     if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
         MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
         if (unlikely(mpm_ctx == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "Error allocating memory");
         }
         memset(mpm_ctx, 0, sizeof(MpmCtx));
         return mpm_ctx;
index 9e97981f7e48b15d61d7abe995d0355142073d37..fb0dda949c0209d11acf8d641d553b56597079c1 100644 (file)
@@ -555,9 +555,8 @@ static void *NapatechStatsLoop(void *arg)
         for (int i = 0; i < stream_cnt; ++i) {
             char *pkts_buf = SCCalloc(1, 32);
             if (unlikely(pkts_buf == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                        "Failed to allocate memory for NAPATECH stream counter.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Failed to allocate memory for NAPATECH stream counter.");
             }
 
             snprintf(pkts_buf, 32, "napa%d.pkts", stream_config[i].stream_id);
@@ -565,27 +564,24 @@ static void *NapatechStatsLoop(void *arg)
 
             char *byte_buf = SCCalloc(1, 32);
             if (unlikely(byte_buf == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                        "Failed to allocate memory for NAPATECH stream counter.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Failed to allocate memory for NAPATECH stream counter.");
             }
             snprintf(byte_buf, 32, "napa%d.bytes", stream_config[i].stream_id);
             stream_counters[i].byte = StatsRegisterCounter(byte_buf, tv);
 
             char *drop_pkts_buf = SCCalloc(1, 32);
             if (unlikely(drop_pkts_buf == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                        "Failed to allocate memory for NAPATECH stream counter.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Failed to allocate memory for NAPATECH stream counter.");
             }
             snprintf(drop_pkts_buf, 32, "napa%d.drop_pkts", stream_config[i].stream_id);
             stream_counters[i].drop_pkts = StatsRegisterCounter(drop_pkts_buf, tv);
 
             char *drop_byte_buf = SCCalloc(1, 32);
             if (unlikely(drop_byte_buf == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                        "Failed to allocate memory for NAPATECH stream counter.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Failed to allocate memory for NAPATECH stream counter.");
             }
             snprintf(drop_byte_buf, 32, "napa%d.drop_byte", stream_config[i].stream_id);
             stream_counters[i].drop_byte = StatsRegisterCounter(drop_byte_buf, tv);
@@ -751,18 +747,16 @@ static uint32_t CountWorkerThreads(void)
                     if (strncmp(lnode->val, "all", 4) == 0) {
                         /* check that the sting in the config file is correctly specified */
                         if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
-                            SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                                    "Only one Napatech port specifier type allowed.");
-                            exit(EXIT_FAILURE);
+                                    FatalError(SC_ERR_FATAL,
+                                               "Only one Napatech port specifier type allowed.");
                         }
                         cpu_spec = CONFIG_SPECIFIER_RANGE;
                         worker_count = UtilCpuGetNumProcessorsConfigured();
                     } else if (strchr(lnode->val, '-')) {
                         /* check that the sting in the config file is correctly specified */
                         if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
-                            SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                                    "Only one Napatech port specifier type allowed.");
-                            exit(EXIT_FAILURE);
+                                    FatalError(SC_ERR_FATAL,
+                                               "Only one Napatech port specifier type allowed.");
                         }
                         cpu_spec = CONFIG_SPECIFIER_RANGE;
 
@@ -787,9 +781,8 @@ static uint32_t CountWorkerThreads(void)
                     } else {
                         /* check that the sting in the config file is correctly specified */
                         if (cpu_spec == CONFIG_SPECIFIER_RANGE) {
-                            SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                                    "Napatech port range specifiers cannot be combined with individual stream specifiers.");
-                            exit(EXIT_FAILURE);
+                                    FatalError(SC_ERR_FATAL,
+                                               "Napatech port range specifiers cannot be combined with individual stream specifiers.");
                         }
                         cpu_spec = CONFIG_SPECIFIER_INDIVIDUAL;
                         ++worker_count;
@@ -938,9 +931,8 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[])
                     }
                 } else {
                     if (stream_spec == CONFIG_SPECIFIER_RANGE) {
-                        SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                                "Napatech range and individual specifiers cannot be combined.");
-                        exit(EXIT_FAILURE);
+                                FatalError(SC_ERR_FATAL,
+                                           "Napatech range and individual specifiers cannot be combined.");
                     }
                     stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
                     if (StringParseUint16(&stream_config[instance_cnt].stream_id,
@@ -1202,15 +1194,13 @@ void NapatechStartStats(void)
             "custom", NapatechStatsLoop, 0);
 
     if (stats_tv == NULL) {
-        SCLogError(SC_ERR_THREAD_CREATE,
-                "Error creating a thread for NapatechStats - Killing engine.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Error creating a thread for NapatechStats - Killing engine.");
     }
 
     if (TmThreadSpawn(stats_tv) != 0) {
-        SCLogError(SC_ERR_THREAD_SPAWN,
-                "Failed to spawn thread for NapatechStats - Killing engine.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Failed to spawn thread for NapatechStats - Killing engine.");
     }
 
 #ifdef NAPATECH_ENABLE_BYPASS
@@ -1225,15 +1215,13 @@ void NapatechStartStats(void)
             "custom", NapatechBufMonitorLoop, 0);
 
     if (buf_monitor_tv == NULL) {
-        SCLogError(SC_ERR_THREAD_CREATE,
-                "Error creating a thread for NapatechBufMonitor - Killing engine.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Error creating a thread for NapatechBufMonitor - Killing engine.");
     }
 
     if (TmThreadSpawn(buf_monitor_tv) != 0) {
-        SCLogError(SC_ERR_THREAD_SPAWN,
-                "Failed to spawn thread for NapatechBufMonitor - Killing engine.");
-        exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL,
+                           "Failed to spawn thread for NapatechBufMonitor - Killing engine.");
     }
 
 
@@ -1439,8 +1427,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
     }
 
     if (is_inline) {
-         SCLogError(SC_ERR_RUNMODE, "Napatech inline mode not supported.  (Only available when Hardware Bypass support is enabled.)");
-         exit(EXIT_FAILURE);
+         FatalError(SC_ERR_FATAL,
+                    "Napatech inline mode not supported.  (Only available when Hardware Bypass support is enabled.)");
     }
 #endif
 
@@ -1455,8 +1443,7 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
      * the array of streams from the conf
      */
     if ((ntports = ConfGetNode("napatech.ports")) == NULL) {
-        SCLogError(SC_ERR_RUNMODE, "Failed retrieving napatech.ports from Conf");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "Failed retrieving napatech.ports from Conf");
     }
 
     /* Loop through all ports in the array */
@@ -1470,9 +1457,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
     TAILQ_FOREACH(port, &ntports->head, next)
     {
         if (port == NULL) {
-            SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
-                    "Couldn't Parse Port Configuration");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Couldn't Parse Port Configuration");
         }
 
         if (NapatechUseHWBypass()) {
@@ -1487,9 +1473,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
 
                 if (ports_spec.first[iteration] == ports_spec.second[iteration]) {
                     if (is_inline) {
-                        SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                                "Error with napatec.ports in conf file.  When running in inline mode the two ports specifying a segment must be different.");
-                        exit(EXIT_FAILURE);
+                                FatalError(SC_ERR_FATAL,
+                                           "Error with napatec.ports in conf file.  When running in inline mode the two ports specifying a segment must be different.");
                     } else {
                         /* SPAN port configuration */
                         is_span_port[ports_spec.first[iteration]] = 1;
@@ -1541,18 +1526,16 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
                     strlcat(ports_spec.str, temp, sizeof(ports_spec.str));
                 }
             } else {
-                SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                        "When using hardware flow bypass ports must be specified as segments. E.g. ports: [0-1, 0-2]");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "When using hardware flow bypass ports must be specified as segments. E.g. ports: [0-1, 0-2]");
             }
 #endif
         } else { // !NapatechUseHWBypass()
             if (strncmp(port->val, "all", 3) == 0) {
                 /* check that the sting in the config file is correctly specified */
                 if (stream_spec != CONFIG_SPECIFIER_UNDEFINED) {
-                    SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                            "Only one Napatech port specifier type is allowed.");
-                    exit(EXIT_FAILURE);
+                            FatalError(SC_ERR_FATAL,
+                                       "Only one Napatech port specifier type is allowed.");
                 }
                 stream_spec = CONFIG_SPECIFIER_RANGE;
 
@@ -1561,9 +1544,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
             } else if (strchr(port->val, '-')) {
                 /* check that the sting in the config file is correctly specified */
                 if (stream_spec != CONFIG_SPECIFIER_UNDEFINED) {
-                    SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                            "Only one Napatech port specifier is allowed when hardware bypass is disabled. (E.g. ports: [0-4], NOT ports: [0-1,2-3])");
-                    exit(EXIT_FAILURE);
+                            FatalError(SC_ERR_FATAL,
+                                       "Only one Napatech port specifier is allowed when hardware bypass is disabled. (E.g. ports: [0-4], NOT ports: [0-1,2-3])");
                 }
                 stream_spec = CONFIG_SPECIFIER_RANGE;
 
@@ -1575,9 +1557,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
             } else {
                 /* check that the sting in the config file is correctly specified */
                 if (stream_spec == CONFIG_SPECIFIER_RANGE) {
-                    SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
-                            "Napatech port range specifiers cannot be combined with individual stream specifiers.");
-                    exit(EXIT_FAILURE);
+                            FatalError(SC_ERR_FATAL,
+                                       "Napatech port range specifiers cannot be combined with individual stream specifiers.");
                 }
                 stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
 
@@ -1827,9 +1808,8 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream)
         }
     } else {
         if (is_inline) {
-            SCLogError(SC_WARN_COMPATIBILITY,
-                    "Napatech Inline operation not supported by this FPGA version.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Napatech Inline operation not supported by this FPGA version.");
         }
 
         if (NapatechIsAutoConfigEnabled()){
index ff3238521d5ce9e3392b0af35501d8505502d5b4..657115a5e5359df19f1d920d0ab61e028566010d 100644 (file)
@@ -85,9 +85,8 @@ void SCDropMainThreadCaps(uint32_t userid, uint32_t groupid)
     if (capng_change_id(userid, groupid, CAPNG_DROP_SUPP_GRP |
             CAPNG_CLEAR_BOUNDING) < 0)
     {
-        SCLogError(SC_ERR_CHANGING_CAPS_FAILED, "capng_change_id for main thread"
-                " failed");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "capng_change_id for main thread"
+                   " failed");
     }
 
     SCLogInfo("dropped the caps for main thread");
@@ -160,16 +159,14 @@ int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, ui
         }
         pw = getpwuid(userid);
        if (pw == NULL) {
-            SCLogError(SC_ERR_UID_FAILED, "unable to get the user ID, "
-                    "check if user exist!!");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "unable to get the user ID, "
+                       "check if user exist!!");
         }
     } else {
         pw = getpwnam(user_name);
         if (pw == NULL) {
-            SCLogError(SC_ERR_UID_FAILED, "unable to get the user ID, "
-                    "check if user exist!!");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "unable to get the user ID, "
+                       "check if user exist!!");
         }
         userid = pw->pw_uid;
     }
@@ -185,9 +182,8 @@ int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, ui
         } else {
             gp = getgrnam(group_name);
             if (gp == NULL) {
-                SCLogError(SC_ERR_GID_FAILED, "unable to get the group"
-                        " ID, check if group exist!!");
-                exit(EXIT_FAILURE);
+                FatalError(SC_ERR_FATAL, "unable to get the group"
+                           " ID, check if group exist!!");
             }
             groupid = gp->gr_gid;
         }
@@ -227,9 +223,8 @@ int SCGetGroupID(const char *group_name, uint32_t *gid)
     } else {
         gp = getgrnam(group_name);
         if (gp == NULL) {
-            SCLogError(SC_ERR_GID_FAILED, "unable to get the group ID,"
-                    " check if group exist!!");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL, "unable to get the group ID,"
+                       " check if group exist!!");
         }
         grpid = gp->gr_gid;
     }
index feee266d57e19087646c64c248cf17cf32568642..fdbf8c6931855388c5ee444cedfcc918a796b9db 100644 (file)
@@ -256,9 +256,8 @@ static SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void)
         memset(ctx, 0x00, sizeof(SCProfileKeywordDetectCtx));
 
         if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
-            SCLogError(SC_ERR_MUTEX,
-                    "Failed to initialize hash table mutex.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to initialize hash table mutex.");
         }
     }
 
index bf8b38d99b1159f907319fc0c5141efb4f4bb047..737eaf3fcc86a681c1c5a9e12c5b26d54d3c4418 100644 (file)
@@ -201,9 +201,8 @@ static SCProfilePrefilterDetectCtx *SCProfilingPrefilterInitCtx(void)
         memset(ctx, 0x00, sizeof(SCProfilePrefilterDetectCtx));
 
         if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
-            SCLogError(SC_ERR_MUTEX,
-                    "Failed to initialize hash table mutex.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to initialize hash table mutex.");
         }
     }
 
index c2e002dea030a521220b8e92d17a85e5aebb2926..11ef3bd569fdb13fc29b62ec8ee14b4814645b4a 100644 (file)
@@ -290,9 +290,7 @@ static SCProfileSghDetectCtx *SCProfilingSghInitCtx(void)
     SCProfileSghDetectCtx *ctx = SCCalloc(1, sizeof(SCProfileSghDetectCtx));
     if (ctx != NULL) {
         if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
-            SCLogError(SC_ERR_MUTEX,
-                    "Failed to initialize mutex.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL, "Failed to initialize mutex.");
         }
     }
 
index 010a25dd70fdc29c9ec4132f9a03223c0ea588c9..af2cd9b43a77db8cbc0ce71b02e5202dc60a07bd 100644 (file)
@@ -577,9 +577,8 @@ static SCProfileDetectCtx *SCProfilingRuleInitCtx(void)
         memset(ctx, 0x00, sizeof(SCProfileDetectCtx));
 
         if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
-            SCLogError(SC_ERR_MUTEX,
-                    "Failed to initialize hash table mutex.");
-            exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL,
+                               "Failed to initialize hash table mutex.");
         }
     }
 
index 71d979f98b4be7ce2978175b1ed02d10fa160e67..af84a5469d71503d8bca8487a75a35b9fa42f16a 100644 (file)
@@ -159,9 +159,8 @@ SCProfilingInit(void)
             profiling_packets_enabled = 1;
 
             if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
-                SCLogError(SC_ERR_MUTEX,
-                        "Failed to initialize packet profiling mutex.");
-                exit(EXIT_FAILURE);
+                        FatalError(SC_ERR_FATAL,
+                                   "Failed to initialize packet profiling mutex.");
             }
             memset(&packet_profile_data4, 0, sizeof(packet_profile_data4));
             memset(&packet_profile_data6, 0, sizeof(packet_profile_data6));
@@ -208,8 +207,7 @@ SCProfilingInit(void)
 
                 profiling_csv_file_name = SCMalloc(PATH_MAX);
                 if (unlikely(profiling_csv_file_name == NULL)) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "out of memory");
-                    exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL, "out of memory");
                 }
                 snprintf(profiling_csv_file_name, PATH_MAX, "%s/%s", log_dir, filename);
 
@@ -243,8 +241,7 @@ SCProfilingInit(void)
 
                 profiling_locks_file_name = SCMalloc(PATH_MAX);
                 if (unlikely(profiling_locks_file_name == NULL)) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
-                    exit(EXIT_FAILURE);
+                    FatalError(SC_ERR_FATAL, "can't duplicate file name");
                 }
 
                 snprintf(profiling_locks_file_name, PATH_MAX, "%s/%s", log_dir, filename);
index 583c1003b4ee6ca65ccb7b27f3f1cb41370e1beb..7b7e797d7fbf0dcc83d25f5a19797186c0f6b3de 100644 (file)
@@ -87,8 +87,7 @@ static void SCRadixAppendToSCRadixUserDataList(SCRadixUserData *new,
     SCRadixUserData *prev = NULL;
 
     if (new == NULL || list == NULL) {
-        SCLogError(SC_ERR_INVALID_ARGUMENTS, "new or list supplied as NULL");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "new or list supplied as NULL");
     }
 
     /* add to the list in descending order.  The reason we do this is for
@@ -187,8 +186,7 @@ static void SCRadixAddNetmaskUserDataToPrefix(SCRadixPrefix *prefix,
                                               void *user)
 {
     if (prefix == NULL || user == NULL) {
-        SCLogError(SC_ERR_INVALID_ARGUMENTS, "prefix or user NULL");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "prefix or user NULL");
     }
 
     SCRadixAppendToSCRadixUserDataList(SCRadixAllocSCRadixUserData(netmask, user),
@@ -211,8 +209,7 @@ static void SCRadixRemoveNetmaskUserDataFromPrefix(SCRadixPrefix *prefix,
     SCRadixUserData *temp = NULL, *prev = NULL;
 
     if (prefix == NULL) {
-        SCLogError(SC_ERR_INVALID_ARGUMENTS, "prefix NULL");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL, "prefix NULL");
     }
 
     prev = temp = prefix->user_data;
@@ -429,8 +426,8 @@ SCRadixTree *SCRadixCreateRadixTree(void (*Free)(void*), void (*PrintData)(void*
     SCRadixTree *tree = NULL;
 
     if ( (tree = SCMalloc(sizeof(SCRadixTree))) == NULL) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
     }
     memset(tree, 0, sizeof(SCRadixTree));
 
@@ -800,8 +797,8 @@ static SCRadixNode *SCRadixAddKey(uint8_t *key_stream, uint16_t key_bitlen,
                                                         sizeof(uint8_t)))) == NULL) {
             SCFree(node->netmasks);
             node->netmasks = NULL;
-            SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixAddKey. Exiting...");
-            exit(EXIT_FAILURE);
+            FatalError(SC_ERR_FATAL,
+                       "Fatal error encountered in SCRadixAddKey. Exiting...");
         }
         node->netmasks = ptmp;
 
index a9772bb40eada0b36cb05bb8ad9624af86e2be5d..efbb756181a64ce8c94fa4e0b2d955451d26f445 100644 (file)
@@ -78,8 +78,8 @@ BmCtx *BoyerMooreCtxInit(const uint8_t *needle, uint16_t needle_len)
 {
     BmCtx *new = SCMalloc(sizeof(BmCtx) + sizeof(uint16_t) * (needle_len + 1));
     if (unlikely(new == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
     }
 
     /* Prepare bad chars */
@@ -87,8 +87,8 @@ BmCtx *BoyerMooreCtxInit(const uint8_t *needle, uint16_t needle_len)
 
     /* Prepare good Suffixes */
     if (PreBmGs(needle, needle_len, new->bmGs) == -1) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
     }
 
 
index b5ff4e4f1e68bf84fd498f5716d45dd37e5cfc11..f062949b0fee53902c144a53eb97e4f97a5740a6 100644 (file)
@@ -258,8 +258,8 @@ static void THashInitConfig(THashTableContext *ctx, const char *cnf_prefix)
     }
     ctx->array = SCMallocAligned(ctx->config.hash_size * sizeof(THashHashRow), CLS);
     if (unlikely(ctx->array == NULL)) {
-        SCLogError(SC_ERR_FATAL, "Fatal error encountered in THashInitConfig. Exiting...");
-        exit(EXIT_FAILURE);
+        FatalError(SC_ERR_FATAL,
+                   "Fatal error encountered in THashInitConfig. Exiting...");
     }
     memset(ctx->array, 0, ctx->config.hash_size * sizeof(THashHashRow));