]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
error: use SC_ENOMEM for alloc errors
authorVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 10:57:29 +0000 (12:57 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 20 Dec 2022 07:51:33 +0000 (08:51 +0100)
62 files changed:
src/conf.c
src/counters.c
src/detect-dsize.c
src/detect-engine-alert.c
src/detect-engine-loader.c
src/detect-engine-threshold.c
src/detect-filemagic.c
src/detect-flowbits.c
src/detect-flowint.c
src/detect-metadata.c
src/detect-parse.c
src/detect-reference.c
src/detect-tag.c
src/detect-transform-xor.c
src/detect.c
src/feature.c
src/log-cf-common.c
src/log-pcap.c
src/log-tlsstore.c
src/output-eve-syslog.c
src/output-lua.c
src/output.c
src/runmode-af-packet.c
src/runmode-dpdk.c
src/runmode-napatech.c
src/runmode-pfring.c
src/runmode-unix-socket.c
src/runmodes.c
src/source-af-packet.c
src/source-dpdk.c
src/source-erf-dag.c
src/source-erf-file.c
src/source-netmap.c
src/source-nfq.c
src/source-pcap-file-directory-helper.c
src/source-pcap-file.c
src/source-pfring.c
src/stream-tcp-reassemble.c
src/suricata.c
src/tm-queues.c
src/tm-threads.c
src/unix-manager.c
src/util-classification-config.c
src/util-detect.c
src/util-device.c
src/util-ebpf.c
src/util-file.c
src/util-ja3.c
src/util-landlock.c
src/util-log-redis.c
src/util-logopenfile.c
src/util-macset.c
src/util-magic.c
src/util-mem.c
src/util-mpm-ac.c
src/util-plugin.c
src/util-prefilter.c
src/util-profiling-rules.c
src/util-proto-name.c
src/util-radix-tree.c
src/util-runmodes.c
src/util-threshold-config.c

index 671da0f8086a36408366b5f155a903dacaeefeeb..d674fdd647e89bd693a13c16b841cd13a52b5e4e 100644 (file)
@@ -84,16 +84,14 @@ static ConfNode *ConfGetNodeOrCreate(const char *name, int final)
         if ((node = ConfNodeLookupChild(parent, key)) == NULL) {
             node = ConfNodeNew();
             if (unlikely(node == NULL)) {
-                SCLogWarning(SC_ERR_MEM_ALLOC,
-                    "Failed to allocate memory for configuration.");
+                SCLogWarning(SC_ENOMEM, "Failed to allocate memory for configuration.");
                 goto end;
             }
             node->name = SCStrdup(key);
             if (unlikely(node->name == NULL)) {
                 ConfNodeFree(node);
                 node = NULL;
-                SCLogWarning(SC_ERR_MEM_ALLOC,
-                    "Failed to allocate memory for configuration.");
+                SCLogWarning(SC_ENOMEM, "Failed to allocate memory for configuration.");
                 goto end;
             }
             node->parent = parent;
index 18d7e195093262f7ed2c2998fec0f880ac078cd6..33ebbe43c7db616f96db0003c6e5e87fcf877702 100644 (file)
@@ -661,7 +661,7 @@ static int StatsOutput(ThreadVars *tv)
         stats_table.stats = SCCalloc(stats_table.nstats, sizeof(StatsRecord));
         if (stats_table.stats == NULL) {
             stats_table.nstats = 0;
-            SCLogError(SC_ERR_MEM_ALLOC, "could not alloc memory for stats");
+            SCLogError(SC_ENOMEM, "could not alloc memory for stats");
             return -1;
         }
 
@@ -670,7 +670,7 @@ static int StatsOutput(ThreadVars *tv)
         stats_table.tstats = SCCalloc(stats_table.ntstats, array_size);
         if (stats_table.tstats == NULL) {
             stats_table.ntstats = 0;
-            SCLogError(SC_ERR_MEM_ALLOC, "could not alloc memory for stats");
+            SCLogError(SC_ENOMEM, "could not alloc memory for stats");
             return -1;
         }
 
index d2eb12fcb7838542d9fad70f1153a4adb572b46b..ccbd0c0fdcd71ced59707e2ae789748f581bbee9 100644 (file)
@@ -139,7 +139,7 @@ static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *
      * and put it in the Signature. */
     sm = SigMatchAlloc();
     if (sm == NULL){
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for SigMatch");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory for SigMatch");
         rs_detect_u16_free(dd);
         goto error;
     }
index b9440b8abf6be0aa793bd8643a16a5856d61fb76..aae6d5a0733e54af5e10949eebddc84fee78f13c 100644 (file)
@@ -224,7 +224,7 @@ void AlertQueueInit(DetectEngineThreadCtx *det_ctx)
     det_ctx->alert_queue_size = 0;
     det_ctx->alert_queue = SCCalloc(packet_alert_max, sizeof(PacketAlert));
     if (det_ctx->alert_queue == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to allocate %" PRIu64 " bytes for the alert queue",
+        FatalError(SC_ENOMEM, "failed to allocate %" PRIu64 " bytes for the alert queue",
                 (uint64_t)(packet_alert_max * sizeof(PacketAlert)));
     }
     det_ctx->alert_queue_capacity = packet_alert_max;
index 9e1d39bd4df52323cca304adb33b4d41041610ec..1451e287516dbc46cf4b36e8bfba4acec93b01fe 100644 (file)
@@ -192,8 +192,10 @@ static int DetectLoadSigFile(DetectEngineCtx *de_ctx, char *sig_file,
                         "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
 
                 if (!SigStringAppend(&de_ctx->sig_stat, sig_file, line, de_ctx->sigerror, (lineno - multiline))) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Error adding sig \"%s\" from "
-                            "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
+                    SCLogError(SC_ENOMEM,
+                            "Error adding sig \"%s\" from "
+                            "file %s at line %" PRId32 "",
+                            line, sig_file, lineno - multiline);
                 }
                 if (de_ctx->sigerror) {
                     de_ctx->sigerror = NULL;
index c007197c07aed218184f8f022fa2c983dbcb773f..3190550fcfd81fa67ecc93954c5b77d004fe696a 100644 (file)
@@ -717,7 +717,7 @@ void ThresholdHashAllocate(DetectEngineCtx *de_ctx)
     de_ctx->ths_ctx.th_size = highest_signum + 1;
     de_ctx->ths_ctx.th_entry = SCCalloc(de_ctx->ths_ctx.th_size, sizeof(DetectThresholdEntry *));
     if (de_ctx->ths_ctx.th_entry == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC,
+        FatalError(SC_ENOMEM,
                 "Error allocating memory for rule "
                 "thresholds (tried to allocate %" PRIu32 " th_entrys for "
                 "rule tracking)",
index b30414a1aa40ccd5fec0f1acf77a08fc9f655d3b..4979f3b62725aff87995cf7662208371bac37776 100644 (file)
@@ -325,7 +325,7 @@ static void *DetectFilemagicThreadInit(void *data /*@unused@*/)
 {
     DetectFilemagicThreadData *t = SCCalloc(1, sizeof(DetectFilemagicThreadData));
     if (unlikely(t == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "couldn't alloc ctx memory");
+        SCLogError(SC_ENOMEM, "couldn't alloc ctx memory");
         return NULL;
     }
 
index 1d0bea34cfdd7e6b104e047ce1b369104c902f31..839753fce6e9115791fd6a80ef82bfbd917c5664 100644 (file)
@@ -417,7 +417,7 @@ int DetectFlowbitsAnalyze(DetectEngineCtx *de_ctx)
     struct FBAnalyze *array = SCCalloc(array_size, sizeof(struct FBAnalyze));
 
     if (array == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate flowbit analyze array");
+        SCLogError(SC_ENOMEM, "Unable to allocate flowbit analyze array");
         return -1;
     }
 
index 3819747cd15869e7b6f8eeb1017e43068b6f5eab..faf4a2bb29dc00d760980833b7fdec412c0c7943 100644 (file)
@@ -317,7 +317,7 @@ static DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx, const char
             sfd->targettype = FLOWINT_TARGET_VAR;
             sfd->target.tvar.name = SCStrdup(varval);
             if (unlikely(sfd->target.tvar.name == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "malloc from strdup failed");
+                SCLogError(SC_ENOMEM, "malloc from strdup failed");
                 goto error;
             }
         }
@@ -328,7 +328,7 @@ static DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx, const char
     /* Set the name of the origin var to modify/compared with the target */
     sfd->name = SCStrdup(varname);
     if (unlikely(sfd->name == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "malloc from strdup failed");
+        SCLogError(SC_ENOMEM, "malloc from strdup failed");
         goto error;
     }
     sfd->idx = VarNameStoreSetupAdd(varname, VAR_TYPE_FLOW_INT);
index c311c1a15517d295fde5fbf3d4b520e14a77e849..de21328d037b4ca59eb8f8ba734b47be6b2041d2 100644 (file)
@@ -207,13 +207,13 @@ static int DetectMetadataParse(DetectEngineCtx *de_ctx, Signature *s, const char
 
         const char *hkey = DetectMedatataHashAdd(de_ctx, key);
         if (hkey == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "can't create metadata key");
+            SCLogError(SC_ENOMEM, "can't create metadata key");
             continue;
         }
 
         const char *hval = DetectMedatataHashAdd(de_ctx, val);
         if (hval == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "can't create metadata value");
+            SCLogError(SC_ENOMEM, "can't create metadata value");
             goto next;
         }
 
index dca3b3e06d80c2aa24bd91c6e1d8f931f3d46858..e218438fb93cbccd5f76d95a2d01123b773ce79f 100644 (file)
@@ -324,7 +324,7 @@ void SigTableApplyStrictCommandlineOption(const char *str)
 
     char *copy = SCStrdup(str);
     if (copy == NULL)
-        FatalError(SC_ERR_MEM_ALLOC, "could not duplicate opt string");
+        FatalError(SC_ENOMEM, "could not duplicate opt string");
 
     char *xsaveptr = NULL;
     char *key = strtok_r(copy, ",", &xsaveptr);
@@ -2525,7 +2525,7 @@ void DetectParseRegexAddToFreeList(DetectParseRegex *detect_parse)
 {
     DetectParseRegex *r = SCCalloc(1, sizeof(*r));
     if (r == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to alloc memory for pcre free list");
+        FatalError(SC_ENOMEM, "failed to alloc memory for pcre free list");
     }
     r->regex = detect_parse->regex;
     r->match = detect_parse->match;
index cbcda0c09cce65734250d0a2da9437ffaac34bdb..458b4ddc2a52c86924671d0da75291338a30a12a 100644 (file)
@@ -155,7 +155,7 @@ static DetectReference *DetectReferenceParse(const char *rawstr, DetectEngineCtx
     /* make a copy so we can free pcre's substring */
     ref->reference = SCStrdup(content);
     if (ref->reference == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "strdup failed: %s", strerror(errno));
+        SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
         goto error;
     }
 
index b3c4d8d429ae2438fb9a2d03cb71baeb73b6bfe6..c9e0a4dbddd6f7fd69ba6330b7a45c2b535d6bac 100644 (file)
@@ -262,7 +262,7 @@ static DetectTagData *DetectTagParse(const char *tagstr)
 
     DetectTagData *real_td = SCMalloc(sizeof(DetectTagData));
     if (unlikely(real_td == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
         goto error;
     }
 
index 53c70eda476aa13025f71be6efb70e404d0b496d..27c7106aad22f5010ac3671251d61e7b030b4dc4 100644 (file)
@@ -81,7 +81,7 @@ static int DetectTransformXorSetup(DetectEngineCtx *de_ctx, Signature *s, const
     // Create pxd from optstr
     DetectTransformXorData *pxd = SCCalloc(1, sizeof(*pxd));
     if (pxd == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed");
+        SCLogError(SC_ENOMEM, "memory allocation failed");
         SCReturnInt(-1);
     }
 
@@ -99,7 +99,7 @@ static int DetectTransformXorSetup(DetectEngineCtx *de_ctx, Signature *s, const
     pxd->length = (uint8_t)(keylen / 2);
     pxd->key = SCMalloc(keylen / 2);
     if (pxd->key == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed");
+        SCLogError(SC_ENOMEM, "memory allocation failed");
         DetectTransformXorFree(de_ctx, pxd);
         SCReturnInt(-1);
     }
index 083af5c87a92aa19a86acbca4bad38221be52b17..7345e8d466109fcd6010fccd1f2dd22ffc18499c 100644 (file)
@@ -970,7 +970,7 @@ void RuleMatchCandidateTxArrayInit(DetectEngineThreadCtx *det_ctx, uint32_t size
     DEBUG_VALIDATE_BUG_ON(det_ctx->tx_candidates);
     det_ctx->tx_candidates = SCCalloc(size, sizeof(RuleMatchCandidateTx));
     if (det_ctx->tx_candidates == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to allocate %"PRIu64" bytes",
+        FatalError(SC_ENOMEM, "failed to allocate %" PRIu64 " bytes",
                 (uint64_t)(size * sizeof(RuleMatchCandidateTx)));
     }
     det_ctx->tx_candidates_size = size;
@@ -1000,7 +1000,7 @@ static int RuleMatchCandidateTxArrayExpand(DetectEngineThreadCtx *det_ctx, const
     uint32_t new_size = needed;
     void *ptmp = SCRealloc(det_ctx->tx_candidates, (new_size * sizeof(RuleMatchCandidateTx)));
     if (ptmp == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to expand to %"PRIu64" bytes",
+        FatalError(SC_ENOMEM, "failed to expand to %" PRIu64 " bytes",
                 (uint64_t)(new_size * sizeof(RuleMatchCandidateTx)));
         // TODO can this be handled more gracefully?
     }
index 8505d9c0f6adcfb50ddbede2db7fe434bb763b78..359e7e519f19415aa80586693ee1903a7eb19e1e 100644 (file)
@@ -85,7 +85,7 @@ static void FeatureInit(void) {
                                            FeatureHashFreeFunc);
 
     if (!feature_hash_table) {
-        FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate feature hash table.");
+        FatalError(sc_errno, "Unable to allocate feature hash table.");
     }
 }
 
@@ -95,7 +95,7 @@ static void FeatureAddEntry(const char *feature_name)
 
     FeatureEntryType *feature = SCCalloc(1, sizeof(*feature));
     if (!feature) {
-        FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate feature entry memory.");
+        FatalError(SC_ENOMEM, "Unable to allocate feature entry memory.");
     }
 
     feature->feature = SCStrdup(feature_name);
index 891dfdc00ee6b654ed43fcc73bdb2ad446b9873e..fbe76b1a9b0bc5c1596b6da1c306c1792c7dbd75 100644 (file)
@@ -40,7 +40,7 @@ LogCustomFormatNode * LogCustomFormatNodeAlloc()
 {
     LogCustomFormatNode * node = SCCalloc(1, sizeof(LogCustomFormatNode));
     if (unlikely(node == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to alloc custom format node");
+        SCLogError(SC_ENOMEM, "Failed to alloc custom format node");
         return NULL;
     }
     return node;
@@ -55,7 +55,7 @@ LogCustomFormat * LogCustomFormatAlloc()
 {
     LogCustomFormat * cf = SCCalloc(1, sizeof(LogCustomFormat));
     if (unlikely(cf == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to alloc custom format");
+        SCLogError(SC_ENOMEM, "Failed to alloc custom format");
         return NULL;
     }
     return cf;
index e1d8d65c4c9216b603b1b2cd13cdbe9bfde117f7..8f9d810ff23cb0bcde1f12b3e0ba8b22279612c3 100644 (file)
@@ -784,16 +784,14 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl)
 
         copy_comp->buffer = SCMalloc(copy_comp->buffer_size);
         if (copy_comp->buffer == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s",
-                    strerror(errno));
+            SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
             SCFree(copy->h);
             SCFree(copy);
             return NULL;
         }
         copy_comp->pcap_buf = SCMalloc(copy_comp->pcap_buf_size);
         if (copy_comp->pcap_buf == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s",
-                    strerror(errno));
+            SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
             SCFree(copy_comp->buffer);
             SCFree(copy->h);
             SCFree(copy);
@@ -1191,7 +1189,7 @@ static void PcapLogDataFree(PcapLogData *pl)
         LZ4F_errorCode_t errcode =
                 LZ4F_freeCompressionContext(pl->compression.lz4f_context);
         if (LZ4F_isError(errcode)) {
-            SCLogWarning(SC_ERR_MEM_ALLOC, "Error freeing lz4 context.");
+            SCLogWarning(SC_EINVAL, "Error freeing lz4 context.");
         }
     }
 #endif /* HAVE_LIBLZ4 */
@@ -1515,8 +1513,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
                     sizeof(struct pcap_pkthdr) + PCAP_SNAPLEN;
             comp->pcap_buf = SCMalloc(comp->pcap_buf_size);
             if (comp->pcap_buf == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s",
-                        strerror(errno));
+                SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
                 exit(EXIT_FAILURE);
             }
             comp->pcap_buf_wrapper = SCFmemopen(comp->pcap_buf,
@@ -1780,8 +1777,8 @@ static int PcapLogOpenFileCtx(PcapLogData *pl)
         (void)SCMkDir(dirfull, 0700);
 
         if ((pf->dirname = SCStrdup(dirfull)) == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for "
-                       "directory name");
+            SCLogError(SC_ENOMEM, "Error allocating memory for "
+                                  "directory name");
             goto error;
         }
 
@@ -1880,7 +1877,7 @@ static int PcapLogOpenFileCtx(PcapLogData *pl)
     }
 
     if ((pf->filename = SCStrdup(pl->filename)) == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory. For filename");
+        SCLogError(SC_ENOMEM, "Error allocating memory. For filename");
         goto error;
     }
     SCLogDebug("Opening pcap file log %s", pf->filename);
index e743828e8a5042d45e60945bbf76fb16677a132c..b6a966dae51c6d96b61bd1b0f2f3f7d9c86c416c 100644 (file)
@@ -117,7 +117,7 @@ static void LogTlsLogPem(LogTlsStoreLogThread *aft, const Packet *p, SSLState *s
                 SCFree(aft->enc_buf);
                 aft->enc_buf = NULL;
                 aft->enc_buf_len = 0;
-                SCLogWarning(SC_ERR_MEM_ALLOC, "Can't allocate data for base64 encoding");
+                SCLogWarning(SC_ENOMEM, "Can't allocate data for base64 encoding");
                 goto end_fp;
             }
             aft->enc_buf = ptmp;
index 7dc0ca90851866fceacbb5575e15ba4b47c66772..f759440207fce5d3298ef6f6534c1d9d4eb8c3f2 100644 (file)
@@ -45,7 +45,7 @@ static int SyslogInit(ConfNode *conf, bool threaded, void **init_data)
 {
     Context *context = SCCalloc(1, sizeof(Context));
     if (context == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate context for %s", OUTPUT_NAME);
+        SCLogError(SC_ENOMEM, "Unable to allocate context for %s", OUTPUT_NAME);
         return -1;
     }
     const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
@@ -101,7 +101,7 @@ void SyslogInitialize(void)
     SCEveFileType *file_type = SCCalloc(1, sizeof(SCEveFileType));
 
     if (file_type == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for eve file type %s", OUTPUT_NAME);
+        FatalError(SC_ENOMEM, "Unable to allocate memory for eve file type %s", OUTPUT_NAME);
     }
 
     file_type->name = OUTPUT_NAME;
index 67a0dcb951d98659b93d2eb13c5b78a0a67b2071..f9ffb2d2551dcae7e7ac8c490f5effdd27cc6baa 100644 (file)
@@ -725,7 +725,7 @@ static OutputInitResult OutputLuaLogInit(ConfNode *conf)
          * on it's needs. */
         OutputModule *om = SCCalloc(1, sizeof(*om));
         if (om == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "calloc() failed");
+            SCLogError(SC_ENOMEM, "calloc() failed");
             goto error;
         }
 
index a66c111756889ae6e91fd5bf38a2b82e095c094c..914679aa26637b9a5c00397d8e9a3c526b1e944e 100644 (file)
@@ -833,8 +833,7 @@ void OutputRegisterFileRotationFlag(int *flag)
 {
     OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
     if (unlikely(flag_entry == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate memory to register file rotation flag");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory to register file rotation flag");
         return;
     }
     flag_entry->flag = flag;
@@ -969,7 +968,7 @@ void OutputRegisterRootLogger(ThreadInitFunc ThreadInit,
 
     RootLogger *logger = SCCalloc(1, sizeof(*logger));
     if (logger == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
+        FatalError(SC_ENOMEM, "failed to alloc root logger");
     }
     logger->ThreadInit = ThreadInit;
     logger->ThreadDeinit = ThreadDeinit;
@@ -983,7 +982,7 @@ static void OutputRegisterActiveLogger(RootLogger *reg)
 {
     RootLogger *logger = SCCalloc(1, sizeof(*logger));
     if (logger == NULL) {
-        FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
+        FatalError(SC_ENOMEM, "failed to alloc root logger");
     }
     logger->ThreadInit = reg->ThreadInit;
     logger->ThreadDeinit = reg->ThreadDeinit;
index 7442332ed1eaf6592e3a08c7fa564bae171f6e4e..2b01edab5573900c9805197662c39d2031717088 100644 (file)
@@ -470,7 +470,7 @@ static void *ParseAFPConfig(const char *iface)
                 RunModeEnablesBypassManager();
                 struct ebpf_timeout_config *ebt = SCCalloc(1, sizeof(struct ebpf_timeout_config));
                 if (ebt == NULL) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Flow bypass alloc error");
+                    SCLogError(SC_ENOMEM, "Flow bypass alloc error");
                 } else {
                     memcpy(ebt, &(aconf->ebpf_t_config), sizeof(struct ebpf_timeout_config));
                     BypassedFlowManagerRegisterCheckFunc(NULL,
index ef99c007a0c61c3257bbed10ce3f95111f0c8b8d..5118d2bd59acffc1f39f21f46b3a3af4c5a1f261 100644 (file)
@@ -154,7 +154,7 @@ static char *AllocArgument(size_t arg_len)
     arg_len += 1; // null character
     ptr = (char *)SCCalloc(arg_len, sizeof(char));
     if (ptr == NULL)
-        FatalError(SC_ERR_MEM_ALLOC, "Could not allocate memory for an argument");
+        FatalError(SC_ENOMEM, "Could not allocate memory for an argument");
 
     SCReturnPtr(ptr, "char *");
 }
@@ -201,7 +201,7 @@ static void ArgumentsInit(struct Arguments *args, unsigned capacity)
     SCEnter();
     args->argv = SCCalloc(capacity, sizeof(ptrdiff_t)); // alloc array of pointers
     if (args->argv == NULL)
-        FatalError(SC_ERR_MEM_ALLOC, "Could not allocate memory for Arguments structure");
+        FatalError(SC_ENOMEM, "Could not allocate memory for Arguments structure");
 
     args->capacity = capacity;
     args->argc = 0;
@@ -276,8 +276,7 @@ static void InitEal()
     // creating a shallow copy for cleanup because rte_eal_init changes array contents
     eal_argv = SCMalloc(args.argc * sizeof(args.argv));
     if (eal_argv == NULL) {
-        FatalError(
-                SC_ERR_MEM_ALLOC, "Failed to allocate memory for the array of DPDK EAL arguments");
+        FatalError(SC_ENOMEM, "Failed to allocate memory for the array of DPDK EAL arguments");
     }
     memcpy(eal_argv, args.argv, args.argc * sizeof(*args.argv));
 
index 584e2d8e468b4090e880eccc1b6a04485a92fa4f..76726926d5a7377428d9915eab5a126372e94c2d 100644 (file)
@@ -189,8 +189,7 @@ static void *NapatechConfigParser(const char *device)
 
     struct NapatechStreamDevConf *conf = SCCalloc(1, sizeof (struct NapatechStreamDevConf));
     if (unlikely(conf == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                "Failed to allocate memory for NAPATECH device name.");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory for NAPATECH device name.");
         return NULL;
     }
 
index 95a837783a521d3b578323ea9d2f5254a4aacbf9..58f3322a0253350ab32698d45a7374c90c3e792c 100644 (file)
@@ -318,8 +318,7 @@ static void *ParsePfringConfig(const char *iface)
         if (strlen(bpf_filter) > 0) {
             pfconf->bpf_filter = SCStrdup(bpf_filter);
             if (unlikely(pfconf->bpf_filter == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC,
-                           "Can't allocate BPF filter string");
+                SCLogError(SC_ENOMEM, "Can't allocate BPF filter string");
             } else {
                 SCLogDebug("Going to use command-line provided bpf filter %s",
                            pfconf->bpf_filter);
@@ -330,8 +329,7 @@ static void *ParsePfringConfig(const char *iface)
             if (strlen(bpf_filter) > 0) {
                 pfconf->bpf_filter = SCStrdup(bpf_filter);
                 if (unlikely(pfconf->bpf_filter == NULL)) {
-                    SCLogError(SC_ERR_MEM_ALLOC,
-                               "Can't allocate BPF filter string");
+                    SCLogError(SC_ENOMEM, "Can't allocate BPF filter string");
                 } else {
                     SCLogDebug("Going to use bpf filter %s",
                                pfconf->bpf_filter);
index 9933cb3e665aae9cd05c4ca357aa6443bc69b44c..3e3fe468b633da634c48bbd1b1bb37e63b306960 100644 (file)
@@ -281,7 +281,7 @@ static TmEcode UnixListAddFile(
         return TM_ECODE_FAILED;
     cfile = SCMalloc(sizeof(PcapFiles));
     if (unlikely(cfile == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate new file");
+        SCLogError(SC_ENOMEM, "Unable to allocate new file");
         return TM_ECODE_FAILED;
     }
     memset(cfile, 0, sizeof(PcapFiles));
@@ -289,7 +289,7 @@ static TmEcode UnixListAddFile(
     cfile->filename = SCStrdup(filename);
     if (unlikely(cfile->filename == NULL)) {
         SCFree(cfile);
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup filename");
+        SCLogError(SC_ENOMEM, "Unable to dup filename");
         return TM_ECODE_FAILED;
     }
 
@@ -298,7 +298,7 @@ static TmEcode UnixListAddFile(
         if (unlikely(cfile->output_dir == NULL)) {
             SCFree(cfile->filename);
             SCFree(cfile);
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup output_dir");
+            SCLogError(SC_ENOMEM, "Unable to dup output_dir");
             return TM_ECODE_FAILED;
         }
     }
@@ -1685,7 +1685,7 @@ static int RunModeUnixSocketMaster(void)
 
     PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand));
     if (unlikely(pcapcmd == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can not allocate pcap command");
+        SCLogError(SC_ENOMEM, "Can not allocate pcap command");
         return 1;
     }
     TAILQ_INIT(&pcapcmd->files);
index d602c25395601bd04106d4cc5f963e8acf9f9b0f..3d56d110af5df06613305d60256043043cf079bc 100644 (file)
@@ -490,11 +490,11 @@ void RunModeRegisterNewRunMode(enum RunModes runmode,
     mode->runmode = runmode;
     mode->name = SCStrdup(name);
     if (unlikely(mode->name == NULL)) {
-        FatalError(SC_ERR_MEM_ALLOC, "Failed to allocate string");
+        FatalError(SC_ENOMEM, "Failed to allocate string");
     }
     mode->description = SCStrdup(description);
     if (unlikely(mode->description == NULL)) {
-        FatalError(SC_ERR_MEM_ALLOC, "Failed to allocate string");
+        FatalError(SC_ENOMEM, "Failed to allocate string");
     }
     mode->RunModeFunc = RunModeFunc;
 
index ebea917db5e232ee5fd49dd7e2905ca416525b64..901173e823ba4ffe5474f1a3bcbc9c4cc6b98a16 100644 (file)
@@ -1689,11 +1689,8 @@ static int AFPSetupRing(AFPThreadVars *ptv, char *devname)
         r = setsockopt(ptv->socket, SOL_PACKET, PACKET_RX_RING,
                 (void *) &ptv->req.v3, sizeof(ptv->req.v3));
         if (r < 0) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-                    "Unable to allocate RX Ring for iface %s: (%d) %s",
-                    devname,
-                    errno,
-                    strerror(errno));
+            SCLogError(SC_ENOMEM, "Unable to allocate RX Ring for iface %s: (%d) %s", devname,
+                    errno, strerror(errno));
             return AFP_FATAL_ERROR;
         }
     } else {
@@ -1712,20 +1709,15 @@ static int AFPSetupRing(AFPThreadVars *ptv, char *devname)
                     SCLogInfo("Memory issue with ring parameters. Retrying.");
                     continue;
                 }
-                SCLogError(SC_ERR_MEM_ALLOC,
-                        "Unable to allocate RX Ring for iface %s: (%d) %s",
-                        devname,
-                        errno,
-                        strerror(errno));
+                SCLogError(SC_EINVAL, "Unable to setup RX Ring for iface %s: (%d) %s", devname,
+                        errno, strerror(errno));
                 return AFP_FATAL_ERROR;
             } else {
                 break;
             }
         }
         if (order < 0) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-                    "Unable to allocate RX Ring for iface %s (order 0 failed)",
-                    devname);
+            SCLogError(SC_EINVAL, "Unable to setup RX Ring for iface %s (order 0 failed)", devname);
             return AFP_FATAL_ERROR;
         }
 #ifdef HAVE_TPACKET_V3
@@ -1748,15 +1740,14 @@ static int AFPSetupRing(AFPThreadVars *ptv, char *devname)
     ptv->ring_buf = mmap(0, ptv->ring_buflen, PROT_READ|PROT_WRITE,
             mmap_flag, ptv->socket, 0);
     if (ptv->ring_buf == MAP_FAILED) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to mmap, error %s",
-                   strerror(errno));
+        SCLogError(SC_ENOMEM, "Unable to mmap, error %s", strerror(errno));
         goto mmap_err;
     }
 #ifdef HAVE_TPACKET_V3
     if (ptv->flags & AFP_TPACKET_V3) {
         ptv->ring.v3 = SCMalloc(ptv->req.v3.tp_block_nr * sizeof(*ptv->ring.v3));
         if (!ptv->ring.v3) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to malloc ptv ring.v3");
+            SCLogError(SC_ENOMEM, "Unable to malloc ptv ring.v3");
             goto postmmap_err;
         }
         for (i = 0; i < ptv->req.v3.tp_block_nr; ++i) {
@@ -1768,7 +1759,7 @@ static int AFPSetupRing(AFPThreadVars *ptv, char *devname)
         /* allocate a ring for each frame header pointer*/
         ptv->ring.v2 = SCCalloc(ptv->req.v2.tp_frame_nr, sizeof(union thdr *));
         if (ptv->ring.v2 == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate frame buf");
+            SCLogError(SC_ENOMEM, "Unable to allocate frame buf");
             goto postmmap_err;
         }
         /* fill the header ring with proper frame ptr*/
index 77342ab44dc0ee5f491f0a64f9042c67c4ca7165..543047e7a9b6ea3fb986dee71822194e67247630 100644 (file)
@@ -429,7 +429,7 @@ static TmEcode ReceiveDPDKThreadInit(ThreadVars *tv, const void *initdata, void
 
     ptv = SCCalloc(1, sizeof(DPDKThreadVars));
     if (unlikely(ptv == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate memory");
+        SCLogError(SC_ENOMEM, "Unable to allocate memory");
         goto fail;
     }
 
index 3f6365a8508c87a91c6a3c17f9fb65469a8d3f47..424ecb3cee4942b664eb25b757868d8a329f93a2 100644 (file)
@@ -510,9 +510,8 @@ ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec)
 
     p = PacketGetFromQueueOrAlloc();
     if (p == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate a Packet on stream: %d, DAG: %s",
-            ewtn->dagstream, ewtn->dagname);
+        SCLogError(SC_ENOMEM, "Failed to allocate a Packet on stream: %d, DAG: %s", ewtn->dagstream,
+                ewtn->dagname);
         SCReturnInt(TM_ECODE_FAILED);
     }
     PKT_SET_SRC(p, PKT_SRC_WIRE);
index eaa750dbc84dc3c18db538b81205154b87efea2f..e1b75b0120f11cadd9e44e7c275d649956b77247 100644 (file)
@@ -131,7 +131,7 @@ TmEcode ReceiveErfFileLoop(ThreadVars *tv, void *data, void *slot)
 
         p = PacketGetFromQueueOrAlloc();
         if (unlikely(p == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate a packet.");
+            SCLogError(SC_ENOMEM, "Failed to allocate a packet.");
             EngineStop();
             SCReturnInt(TM_ECODE_FAILED);
         }
@@ -235,7 +235,7 @@ ReceiveErfFileThreadInit(ThreadVars *tv, const void *initdata, void **data)
 
     ErfFileThreadVars *etv = SCMalloc(sizeof(ErfFileThreadVars));
     if (unlikely(etv == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF file thread vars.");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory for ERF file thread vars.");
         fclose(erf);
         SCReturnInt(TM_ECODE_FAILED);
     }
index 7c233fb2c9c297a2e4e18cdf7fa244262ca067dd..61de69fe36ae2302009ddd712f6a146ed540ae5c 100644 (file)
@@ -318,7 +318,7 @@ static int NetmapOpen(NetmapIfaceSettings *ns, NetmapDevice **pdevice, int verbo
     NetmapDevice *pdev = NULL, *spdev = NULL;
     pdev = SCCalloc(1, sizeof(*pdev));
     if (unlikely(pdev == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed");
+        SCLogError(SC_ENOMEM, "Memory allocation failed");
         goto error;
     }
     SC_ATOMIC_INIT(pdev->threads_run);
@@ -512,7 +512,7 @@ static TmEcode ReceiveNetmapThreadInit(ThreadVars *tv, const void *initdata, voi
 
     NetmapThreadVars *ntv = SCCalloc(1, sizeof(*ntv));
     if (unlikely(ntv == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Memory allocation failed");
+        SCLogError(SC_ENOMEM, "Memory allocation failed");
         goto error;
     }
 
index d1a916f976daf162ce8b2b7db61ba0666e233a81..fcf28cb44a379dc71fc55b619c7b731fc64b3805 100644 (file)
@@ -891,7 +891,7 @@ int NFQParseAndRegisterQueues(const char *queues)
     // We do realloc() to preserve previously registered queues
     void *ptmp = SCRealloc(g_nfq_t, (receive_queue_num + num_queues) * sizeof(NFQThreadVars));
     if (ptmp == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate NFQThreadVars");
+        SCLogError(SC_ENOMEM, "Unable to allocate NFQThreadVars");
         NFQContextsClean();
         exit(EXIT_FAILURE);
     }
@@ -900,7 +900,7 @@ int NFQParseAndRegisterQueues(const char *queues)
 
     ptmp = SCRealloc(g_nfq_q, (receive_queue_num + num_queues) * sizeof(NFQQueueVars));
     if (ptmp == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate NFQQueueVars");
+        SCLogError(SC_ENOMEM, "Unable to allocate NFQQueueVars");
         NFQContextsClean();
         exit(EXIT_FAILURE);
     }
index 43ccadf69772f4456be836c12317f759b592bb38..d409810b285166409977f655405a948ca5a6a64a 100644 (file)
@@ -367,14 +367,14 @@ TmEcode PcapDirectoryPopulateBuffer(PcapFileDirectoryVars *pv,
 
             file_to_add = SCCalloc(1, sizeof(PendingFile));
             if (unlikely(file_to_add == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate pending file");
+                SCLogError(SC_ENOMEM, "Failed to allocate pending file");
 
                 SCReturnInt(TM_ECODE_FAILED);
             }
 
             file_to_add->filename = SCStrdup(pathbuff);
             if (unlikely(file_to_add->filename == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Failed to copy filename");
+                SCLogError(SC_ENOMEM, "Failed to copy filename");
                 CleanupPendingFile(file_to_add);
 
                 SCReturnInt(TM_ECODE_FAILED);
@@ -434,14 +434,14 @@ TmEcode PcapDirectoryDispatchForTimeRange(PcapFileDirectoryVars *pv,
 
                 PcapFileFileVars *pftv = SCMalloc(sizeof(PcapFileFileVars));
                 if (unlikely(pftv == NULL)) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate PcapFileFileVars");
+                    SCLogError(SC_ENOMEM, "Failed to allocate PcapFileFileVars");
                     SCReturnInt(TM_ECODE_FAILED);
                 }
                 memset(pftv, 0, sizeof(PcapFileFileVars));
 
                 pftv->filename = SCStrdup(current_file->filename);
                 if (unlikely(pftv->filename == NULL)) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
+                    SCLogError(SC_ENOMEM, "Failed to allocate filename");
                     CleanupPcapFileFileVars(pftv);
                     SCReturnInt(TM_ECODE_FAILED);
                 }
index 97f424943efca2ba6ecc5d5c06092a930d92cd03..67987102e2b0b19a3348064911a6e6d697daf2c3 100644 (file)
@@ -227,7 +227,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
     } else {
         ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
         if (unlikely(ptv->shared.bpf_string == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate bpf_string");
+            SCLogError(SC_ENOMEM, "Failed to allocate bpf_string");
 
             CleanupPcapFileThreadVars(ptv);
 
@@ -252,7 +252,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
         SCLogDebug("argument %s was a file", (char *)initdata);
         PcapFileFileVars *pv = SCMalloc(sizeof(PcapFileFileVars));
         if (unlikely(pv == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate file vars");
+            SCLogError(SC_ENOMEM, "Failed to allocate file vars");
             CleanupPcapFileThreadVars(ptv);
             SCReturnInt(TM_ECODE_OK);
         }
@@ -260,7 +260,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
 
         pv->filename = SCStrdup((char *)initdata);
         if (unlikely(pv->filename == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
+            SCLogError(SC_ENOMEM, "Failed to allocate filename");
             CleanupPcapFileFileVars(pv);
             CleanupPcapFileThreadVars(ptv);
             SCReturnInt(TM_ECODE_OK);
@@ -282,7 +282,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
         SCLogInfo("Argument %s was a directory", (char *)initdata);
         PcapFileDirectoryVars *pv = SCMalloc(sizeof(PcapFileDirectoryVars));
         if (unlikely(pv == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate directory vars");
+            SCLogError(SC_ENOMEM, "Failed to allocate directory vars");
             closedir(directory);
             CleanupPcapFileThreadVars(ptv);
             SCReturnInt(TM_ECODE_OK);
@@ -291,7 +291,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
 
         pv->filename = SCStrdup((char*)initdata);
         if (unlikely(pv->filename == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
+            SCLogError(SC_ENOMEM, "Failed to allocate filename");
             CleanupPcapFileDirectoryVars(pv);
             CleanupPcapFileThreadVars(ptv);
             SCReturnInt(TM_ECODE_OK);
index bb30df619e5c7dba08812c1d5e6e5b6ff3a5b70b..4b8205f56ce74380d4b9436e403704e561fea943 100644 (file)
@@ -507,7 +507,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat
 
     ptv->interface = SCStrdup(pfconf->iface);
     if (unlikely(ptv->interface == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate device string");
+        SCLogError(SC_ENOMEM, "Unable to allocate device string");
         SCFree(ptv);
         SCReturnInt(TM_ECODE_FAILED);
     }
@@ -603,7 +603,7 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **dat
     if (pfconf->bpf_filter) {
         ptv->bpf_filter = SCStrdup(pfconf->bpf_filter);
         if (unlikely(ptv->bpf_filter == NULL)) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Set PF_RING bpf filter failed.");
+            SCLogError(SC_ENOMEM, "Set PF_RING bpf filter failed.");
         } else {
             SCMutexLock(&pfring_bpf_set_filter_lock);
             rc = pfring_set_bpf_filter(ptv->pd, ptv->bpf_filter);
index 4d0a36a68db76bc160797fb0701b897fd7025c75..4dc2cbd76a9a18a7ae6b4a5077ca5080c3f569ec 100644 (file)
@@ -270,8 +270,8 @@ static void *TcpSegmentPoolAlloc(void)
 
         seg->pcap_hdr_storage = SCCalloc(1, sizeof(TcpSegmentPcapHdrStorage));
         if (seg->pcap_hdr_storage == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for "
-                                         "TcpSegmentPcapHdrStorage");
+            SCLogError(SC_ENOMEM, "Unable to allocate memory for "
+                                  "TcpSegmentPcapHdrStorage");
             SCFree(seg);
             return NULL;
         } else {
@@ -279,9 +279,9 @@ static void *TcpSegmentPoolAlloc(void)
             seg->pcap_hdr_storage->pkt_hdr =
                     SCCalloc(1, sizeof(uint8_t) * TCPSEG_PKT_HDR_DEFAULT_SIZE);
             if (seg->pcap_hdr_storage->pkt_hdr == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for "
-                                             "packet header data within "
-                                             "TcpSegmentPcapHdrStorage");
+                SCLogError(SC_ENOMEM, "Unable to allocate memory for "
+                                      "packet header data within "
+                                      "TcpSegmentPcapHdrStorage");
                 SCFree(seg->pcap_hdr_storage);
                 SCFree(seg);
                 return NULL;
index f85402c37da46181ec318971202f015617ce4a96..ab8b542e32b895baf6eee43ac3e753b2604dc8a5 100644 (file)
@@ -525,7 +525,7 @@ static void SetBpfStringFromFile(char *filename)
 
     bpf_filter = SCMalloc(bpf_len);
     if (unlikely(bpf_filter == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate buffer for bpf filter in file %s", filename);
+        SCLogError(SC_ENOMEM, "Failed to allocate buffer for bpf filter in file %s", filename);
         exit(EXIT_FAILURE);
     }
     memset(bpf_filter, 0x00, bpf_len);
@@ -1575,8 +1575,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             else if(strcmp((long_opts[option_index]).name, "pidfile") == 0) {
                 suri->pid_filename = SCStrdup(optarg);
                 if (suri->pid_filename == NULL) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "strdup failed: %s",
-                        strerror(errno));
+                    SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
                     return TM_ECODE_FAILED;
                 }
             }
@@ -1764,7 +1763,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
                     suri->strict_rule_parsing_string = SCStrdup(optarg);
                 }
                 if (suri->strict_rule_parsing_string == NULL) {
-                    FatalError(SC_ERR_MEM_ALLOC, "failed to duplicate 'strict' string");
+                    FatalError(SC_ENOMEM, "failed to duplicate 'strict' string");
                 }
             } else {
                 int r = ExceptionSimulationCommandlineParser(
@@ -2074,7 +2073,7 @@ static int MayDaemonize(SCInstance *suri)
         /* The pid file name may be in config memory, but is needed later. */
         suri->pid_filename = SCStrdup(pid_filename);
         if (suri->pid_filename == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "strdup failed: %s", strerror(errno));
+            SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
             return TM_ECODE_FAILED;
         }
     }
index 6c745bc275b9c3b4c7c264d0c6f07c824309ae6d..248cd71d9017cc3f6f926facc943ee25539c7c14 100644 (file)
@@ -36,18 +36,18 @@ Tmq *TmqCreateQueue(const char *name)
 {
     Tmq *q = SCCalloc(1, sizeof(*q));
     if (q == NULL)
-        FatalError(SC_ERR_MEM_ALLOC, "SCCalloc failed");
+        FatalError(SC_ENOMEM, "SCCalloc failed");
 
     q->name = SCStrdup(name);
     if (q->name == NULL)
-        FatalError(SC_ERR_MEM_ALLOC, "SCStrdup failed");
+        FatalError(SC_ENOMEM, "SCStrdup failed");
 
     q->id = tmq_id++;
     q->is_packet_pool = (strcmp(q->name, "packetpool") == 0);
     if (!q->is_packet_pool) {
         q->pq = PacketQueueAlloc();
         if (q->pq == NULL)
-            FatalError(SC_ERR_MEM_ALLOC, "PacketQueueAlloc failed");
+            FatalError(SC_ENOMEM, "PacketQueueAlloc failed");
     }
 
     TAILQ_INSERT_HEAD(&tmq_list, q, next);
index b7b2be628e0d8bdc53451bc1db1defad369b3a70..1bea0fd00b04bb2dfcd52c0ccca3068d3d4d3d33 100644 (file)
@@ -282,7 +282,7 @@ static void *TmThreadsSlotPktAcqLoop(void *td)
         } else if (slot->tm_id == TMM_FLOWWORKER) {
             tv->stream_pq_local = SCCalloc(1, sizeof(PacketQueue));
             if (tv->stream_pq_local == NULL)
-                FatalError(SC_ERR_MEM_ALLOC, "failed to alloc PacketQueue");
+                FatalError(SC_ENOMEM, "failed to alloc PacketQueue");
             SCMutexInit(&tv->stream_pq_local->mutex_q, NULL);
             tv->stream_pq = tv->stream_pq_local;
             tv->tm_flowworker = slot;
@@ -412,7 +412,7 @@ static void *TmThreadsSlotVar(void *td)
         } else if (s->tm_id == TMM_FLOWWORKER) {
             tv->stream_pq_local = SCCalloc(1, sizeof(PacketQueue));
             if (tv->stream_pq_local == NULL)
-                FatalError(SC_ERR_MEM_ALLOC, "failed to alloc PacketQueue");
+                FatalError(SC_ENOMEM, "failed to alloc PacketQueue");
             SCMutexInit(&tv->stream_pq_local->mutex_q, NULL);
             tv->stream_pq = tv->stream_pq_local;
             tv->tm_flowworker = s;
index a6fde27c96ff94b876487609092d5910da65fbb9..313de0f9683f675240182f02dae647a881c2c4ad 100644 (file)
@@ -236,12 +236,12 @@ static UnixClient *UnixClientAlloc(void)
 {
     UnixClient *uclient = SCMalloc(sizeof(UnixClient));
     if (unlikely(uclient == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate new client");
+        SCLogError(SC_ENOMEM, "Can't allocate new client");
         return NULL;
     }
     uclient->mbuf = MemBufferCreateNew(CLIENT_BUFFER_SIZE);
     if (uclient->mbuf == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate new client send buffer");
+        SCLogError(sc_errno, "Can't allocate new client send buffer");
         SCFree(uclient);
         return NULL;
     }
@@ -985,12 +985,12 @@ TmEcode UnixManagerRegisterCommand(const char * keyword,
 
     cmd = SCMalloc(sizeof(Command));
     if (unlikely(cmd == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't alloc cmd");
+        SCLogError(SC_ENOMEM, "Can't alloc cmd");
         SCReturnInt(TM_ECODE_FAILED);
     }
     cmd->name = SCStrdup(keyword);
     if (unlikely(cmd->name == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't alloc cmd name");
+        SCLogError(SC_ENOMEM, "Can't alloc cmd name");
         SCFree(cmd);
         SCReturnInt(TM_ECODE_FAILED);
     }
@@ -1026,7 +1026,7 @@ TmEcode UnixManagerRegisterBackgroundTask(TmEcode (*Func)(void *),
 
     task = SCMalloc(sizeof(Task));
     if (unlikely(task == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't alloc task");
+        SCLogError(SC_ENOMEM, "Can't alloc task");
         SCReturnInt(TM_ECODE_FAILED);
     }
     task->Func = Func;
index 669338e1a64e3a0947b69ea9f65202bb51058edb..4a81be55f50ed31f1c8748b8269cf8f35df6306b 100644 (file)
@@ -213,7 +213,7 @@ static char *SCClassConfStringToLowercase(const char *str)
     char *temp_str = NULL;
 
     if ( (new_str = SCStrdup(str)) == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
         return NULL;
     }
 
@@ -404,7 +404,7 @@ static SCClassConfClasstype *SCClassConfAllocClasstype(uint16_t classtype_id,
 
     if (classtype_desc != NULL &&
         (ct->classtype_desc = SCStrdup(classtype_desc)) == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
 
         SCClassConfDeAllocClasstype(ct);
         return NULL;
index 37ed2e3c40b53602c8998d44a3c60484c7b47f80..59c5d656fa122bf3744528160d658f0082e44cdf 100644 (file)
@@ -65,13 +65,13 @@ static int SigStringAddSig(SigString *sig, const char *sig_file,
 
     sig->filename = SCStrdup(sig_file);
     if (sig->filename == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
         return 0;
     }
 
     sig->sig_str = SCStrdup(sig_str);
     if (sig->sig_str == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
         SCFree(sig->filename);
         return 0;
     }
@@ -79,7 +79,7 @@ static int SigStringAddSig(SigString *sig, const char *sig_file,
     if (sig_error) {
         sig->sig_error = SCStrdup(sig_error);
         if (sig->sig_error == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+            SCLogError(SC_ENOMEM, "Error allocating memory");
             SCFree(sig->filename);
             SCFree(sig->sig_str);
             return 0;
index 26220ecfb35bb5851efe97cdfe2cfea6d5f290f1..11432863816fe392708c0988446adaa1e1ddc98d 100644 (file)
@@ -509,7 +509,7 @@ int LiveDevUseBypass(LiveDevice *dev)
 {
     BypassInfo *bpinfo = SCCalloc(1, sizeof(*bpinfo));
     if (bpinfo == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bypass info structure");
+        SCLogError(SC_ENOMEM, "Can't allocate bypass info structure");
         return -1;
     }
 
index 2d7b0ad22093bd8d20470de50a34714a7f0fa281..b4a07785287a4a25b6bd38c8e56d250af1c71503 100644 (file)
@@ -218,7 +218,7 @@ static int EBPFLoadPinnedMaps(LiveDevice *livedev, struct ebpf_timeout_config *c
 
     struct bpf_maps_info *bpf_map_data = SCCalloc(1, sizeof(*bpf_map_data));
     if (bpf_map_data == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bpf map array");
+        SCLogError(SC_ENOMEM, "Can't allocate bpf map array");
         return -1;
     }
 
@@ -288,7 +288,7 @@ alloc_error:
         SCFree(bpf_map_data->array[i].name);
     }
     bpf_map_data->last = 0;
-    SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bpf map name");
+    SCLogError(SC_ENOMEM, "Can't allocate bpf map name");
     return -1;
 }
 
@@ -336,8 +336,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section,
      * locked memory so we set it to unlimited to avoid a ENOPERM error */
     struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
     if (setrlimit(RLIMIT_MEMLOCK, &r) != 0) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to lock memory: %s (%d)",
-                   strerror(errno), errno);
+        SCLogError(SC_ENOMEM, "Unable to lock memory: %s (%d)", strerror(errno), errno);
         return -1;
     }
 
@@ -422,7 +421,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section,
      * that we use bpf_maps_info:: */
     struct bpf_maps_info *bpf_map_data = SCCalloc(1, sizeof(*bpf_map_data));
     if (bpf_map_data == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bpf map array");
+        SCLogError(SC_ENOMEM, "Can't allocate bpf map array");
         return -1;
     }
 
@@ -438,7 +437,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section,
         snprintf(bpf_map_data->array[bpf_map_data->last].iface, IFNAMSIZ,
                  "%s", iface);
         if (!bpf_map_data->array[bpf_map_data->last].name) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to duplicate map name");
+            SCLogError(SC_ENOMEM, "Unable to duplicate map name");
             BpfMapsInfoFree(bpf_map_data);
             return -1;
         }
index ba8ea39469d806153c91bcd96110a33c00dd6645..3ffba673f361914107c99867d3fd90904904c647 100644 (file)
@@ -491,7 +491,7 @@ FileContainer *FileContainerAlloc(void)
 {
     FileContainer *new = SCMalloc(sizeof(FileContainer));
     if (unlikely(new == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
+        SCLogError(SC_ENOMEM, "Error allocating mem");
         return NULL;
     }
     memset(new, 0, sizeof(FileContainer));
@@ -552,7 +552,7 @@ static File *FileAlloc(const uint8_t *name, uint16_t name_len)
 {
     File *new = SCMalloc(sizeof(File));
     if (unlikely(new == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
+        SCLogError(SC_ENOMEM, "Error allocating mem");
         return NULL;
     }
     memset(new, 0, sizeof(File));
index 78a49a61bddbfd6ae9264a1f49ce89825c114a73..dbbf28063f900cb1d94ad9e80b86c72b06f30a27 100644 (file)
@@ -83,7 +83,7 @@ static int Ja3BufferResizeIfFull(JA3Buffer *buffer, uint32_t len)
         buffer->size *= 2;
         char *tmp = SCRealloc(buffer->data, buffer->size);
         if (tmp == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error resizing JA3 buffer");
+            SCLogError(SC_ENOMEM, "Error resizing JA3 buffer");
             return -1;
         }
         buffer->data = tmp;
@@ -177,8 +177,7 @@ int Ja3BufferAddValue(JA3Buffer **buffer, uint32_t value)
     if ((*buffer)->data == NULL) {
         (*buffer)->data = SCMalloc(JA3_BUFFER_INITIAL_SIZE);
         if ((*buffer)->data == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC,
-                       "Error allocating memory for JA3 data");
+            SCLogError(SC_ENOMEM, "Error allocating memory for JA3 data");
             Ja3BufferFree(buffer);
             return -1;
         }
@@ -226,8 +225,7 @@ char *Ja3GenerateHash(JA3Buffer *buffer)
 
     char *ja3_hash = SCMalloc(SC_MD5_HEX_LEN + 1);
     if (ja3_hash == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-                   "Error allocating memory for JA3 hash");
+        SCLogError(SC_ENOMEM, "Error allocating memory for JA3 hash");
         return NULL;
     }
 
index fa15a08e049e89863ac2a5f6a0c36f23d5ec80ba..4c6c3dba47ae162ea8acc1fcd1858a194ae33777 100644 (file)
@@ -90,7 +90,7 @@ static inline struct landlock_ruleset *LandlockCreateRuleset(void)
 {
     struct landlock_ruleset *ruleset = SCCalloc(1, sizeof(struct landlock_ruleset));
     if (ruleset == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Can't alloc landlock ruleset");
+        SCLogError(SC_ENOMEM, "Can't alloc landlock ruleset");
         return NULL;
     }
 
index bfaf29a5a91701840bb634c4b470f2b9eddc4b11..cec126505aaceae41a28467d2fee67f9b138d988 100644 (file)
@@ -215,7 +215,7 @@ static int SCConfLogReopenAsyncRedis(LogFileCtx *log_ctx)
     }
 
     if (ctx->async == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocate redis async.");
+        SCLogError(SC_ENOMEM, "Error allocate redis async.");
         ctx->tried = time(NULL);
         return -1;
     }
index 0b8f9b4e6e2c51a988c0affd53279cd392a17a55..b9731ad35110b7f683fdb61eb02c4030a30b76ef 100644 (file)
@@ -331,20 +331,20 @@ bool SCLogOpenThreadedFile(
 {
         parent_ctx->threads = SCCalloc(1, sizeof(LogThreadedFileCtx));
         if (!parent_ctx->threads) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate threads container");
+            SCLogError(SC_ENOMEM, "Unable to allocate threads container");
             return false;
         }
 
         parent_ctx->threads->append = SCStrdup(append == NULL ? DEFAULT_LOG_MODE_APPEND : append);
         if (!parent_ctx->threads->append) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate threads append setting");
+            SCLogError(SC_ENOMEM, "Unable to allocate threads append setting");
             goto error_exit;
         }
 
         parent_ctx->threads->slot_count = slot_count;
         parent_ctx->threads->lf_slots = SCCalloc(slot_count, sizeof(LogFileCtx *));
         if (!parent_ctx->threads->lf_slots) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate thread slots");
+            SCLogError(SC_ENOMEM, "Unable to allocate thread slots");
             goto error_exit;
         }
         SCLogDebug("Allocated %d file context pointers for threaded array",
@@ -586,8 +586,7 @@ SCConfLogOpenGeneric(ConfNode *conf,
     }
     log_ctx->filename = SCStrdup(log_path);
     if (unlikely(log_ctx->filename == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC,
-            "Failed to allocate memory for filename");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory for filename");
         return -1;
     }
 
@@ -696,7 +695,7 @@ LogFileCtx *LogFileEnsureExists(LogFileCtx *parent_ctx, int thread_id)
 
     if (new_array == NULL) {
         SCMutexUnlock(&parent_ctx->threads->mutex);
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to increase file context array size to %d", new_size);
+        SCLogError(SC_ENOMEM, "Unable to increase file context array size to %d", new_size);
         return NULL;
     }
 
@@ -775,7 +774,7 @@ static bool LogFileNewThreadedCtx(LogFileCtx *parent_ctx, const char *log_path,
 {
     LogFileCtx *thread = SCCalloc(1, sizeof(LogFileCtx));
     if (!thread) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate thread file context slot %d", thread_id);
+        SCLogError(SC_ENOMEM, "Unable to allocate thread file context slot %d", thread_id);
         return false;
     }
 
@@ -793,8 +792,7 @@ static bool LogFileNewThreadedCtx(LogFileCtx *parent_ctx, const char *log_path,
         }
         thread->filename = SCStrdup(fname);
         if (!thread->filename) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Unable to duplicate filename for context slot %d",
-                    thread_id);
+            SCLogError(SC_ENOMEM, "Unable to duplicate filename for context slot %d", thread_id);
             goto error;
         }
         thread->is_regular = true;
index 0896e907cda7619176615ec70d325280bfe86f6a..efa74ce0f080d5cb02b3bd215c2532dfd041d9c2 100644 (file)
@@ -95,7 +95,7 @@ MacSet *MacSetInit(int size)
     }
     ms = SCCalloc(1, sizeof(*ms));
     if (unlikely(ms == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate MacSet memory");
+        SCLogError(SC_ENOMEM, "Unable to allocate MacSet memory");
         return NULL;
     }
     (void) SC_ATOMIC_ADD(flow_memuse, (sizeof(*ms)));
@@ -133,8 +133,8 @@ static inline void MacUpdateEntry(MacSet *ms, uint8_t *addr, int side, ThreadVar
                     }
                     ms->buf[side] = SCCalloc(ms->size, sizeof(MacAddr));
                     if (unlikely(ms->buf[side] == NULL)) {
-                        SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate "
-                                                     "MacSet memory");
+                        SCLogError(SC_ENOMEM, "Unable to allocate "
+                                              "MacSet memory");
                         return;
                     }
                     (void) SC_ATOMIC_ADD(flow_memuse, (ms->size * sizeof(MacAddr)));
index 941c98f56c6a802402e8a498df87062aaec0c498..e742d18def22390d440d81d4daa21aa2fdf7ece0 100644 (file)
@@ -113,7 +113,7 @@ char *MagicThreadLookup(magic_t *ctx, const uint8_t *buf, uint32_t buflen)
         if (result != NULL) {
             magic = SCStrdup(result);
             if (unlikely(magic == NULL)) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup magic");
+                SCLogError(SC_ENOMEM, "Unable to dup magic");
             }
         }
     }
index 551d05b78ef43a6f84de577e857407f00642a507..2f612fabd7703f48fe202f6f3cd84158000b20e4 100644 (file)
@@ -32,8 +32,10 @@ void *SCMallocFunc(const size_t sz)
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
             uintmax_t scmalloc_size_ = (uintmax_t)sz;
-            SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes", strerror(errno), scmalloc_size_);
+            SCLogError(SC_ENOMEM,
+                    "SCMalloc failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes",
+                    strerror(errno), scmalloc_size_);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -45,8 +47,10 @@ void *SCReallocFunc(void *ptr, const size_t size)
     void *ptrmem = realloc(ptr, size);
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)size);
+            SCLogError(SC_ENOMEM,
+                    "SCRealloc failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes",
+                    strerror(errno), (uintmax_t)size);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -58,8 +62,10 @@ void *SCCallocFunc(const size_t nm, const size_t sz)
     void *ptrmem = calloc(nm, sz);
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)nm*sz);
+            SCLogError(SC_ENOMEM,
+                    "SCCalloc failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes",
+                    strerror(errno), (uintmax_t)nm * sz);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -72,8 +78,10 @@ char *SCStrdupFunc(const char *s)
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
             size_t _scstrdup_len = strlen(s);
-            SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_scstrdup_len);
+            SCLogError(SC_ENOMEM,
+                    "SCStrdup failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes",
+                    strerror(errno), (uintmax_t)_scstrdup_len);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -93,8 +101,10 @@ char *SCStrndupFunc(const char *s, size_t n)
 #endif
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCStrndup failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)(n + 1));
+            SCLogError(SC_ENOMEM,
+                    "SCStrndup failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes",
+                    strerror(errno), (uintmax_t)(n + 1));
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -107,8 +117,10 @@ void *SCMallocAlignedFunc(const size_t size, const size_t align)
     void *ptrmem = _mm_malloc(size, align);
     if (unlikely(ptrmem == NULL)) {
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCMallocAligned(posix_memalign) failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes, alignment %"PRIuMAX, strerror(errno), (uintmax_t)size, (uintmax_t)align);
+            SCLogError(SC_ENOMEM,
+                    "SCMallocAligned(posix_memalign) failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
+                    strerror(errno), (uintmax_t)size, (uintmax_t)align);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
@@ -121,8 +133,10 @@ void *SCMallocAlignedFunc(const size_t size, const size_t align)
             ptrmem = NULL;
         }
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
-            SCLogError(SC_ERR_MEM_ALLOC, "SCMallocAligned(posix_memalign) failed: %s, while trying "
-                "to allocate %"PRIuMAX" bytes, alignment %"PRIuMAX, strerror(errno), (uintmax_t)size, (uintmax_t)align);
+            SCLogError(SC_ENOMEM,
+                    "SCMallocAligned(posix_memalign) failed: %s, while trying "
+                    "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
+                    strerror(errno), (uintmax_t)size, (uintmax_t)align);
             FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
         }
     }
index 36d368b298068dae1d95afce920ac0ad3d2d3345..5a13d3ae6f6b077cffc86125e6d5bfed98de4388 100644 (file)
@@ -127,9 +127,10 @@ static inline size_t SCACCheckSafeSizetMult(size_t a, size_t b)
 {
     /* check for safety of multiplication operation */
     if (b > 0 && a > SIZE_MAX / b) {
-        SCLogError(SC_ERR_MEM_ALLOC, "%"PRIuMAX" * %"PRIuMAX" > %"
-                   PRIuMAX" would overflow size_t calculating buffer size",
-                   (uintmax_t) a, (uintmax_t) b, (uintmax_t) SIZE_MAX);
+        SCLogError(SC_EINVAL,
+                "%" PRIuMAX " * %" PRIuMAX " > %" PRIuMAX
+                " would overflow size_t calculating buffer size",
+                (uintmax_t)a, (uintmax_t)b, (uintmax_t)SIZE_MAX);
         exit(EXIT_FAILURE);
     }
     return a * b;
index b0e9d6286631b12e5b92c31c00bf3d9b30a83b5d..f2e5e4a1cfd51bca46ee7d9490bbc5e6042236c5 100644 (file)
@@ -54,7 +54,7 @@ bool RegisterPlugin(SCPlugin *plugin, void *lib)
 
     PluginListNode *node = SCCalloc(1, sizeof(*node));
     if (node == NULL) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for plugin");
+        SCLogError(SC_ENOMEM, "Failed to allocate memory for plugin");
         return false;
     }
     node->plugin = plugin;
index ca59a1b48e4a943af0da6e7bc1f91095d8efd9e9..dd81be1cf3c1008d9cb57e921e58fc967d1b6042 100644 (file)
@@ -83,8 +83,8 @@ PrefilterAddSidsResize(PrefilterRuleStore *pmq, uint32_t new_size)
                                          new_size * sizeof(SigIntId));
         if (unlikely(new_array == NULL)) {
 
-            SCLogError(SC_ERR_MEM_ALLOC, "Failed to realloc PatternMatchQueue"
-                       " rule ID array. Some signature ID matches lost");
+            SCLogError(SC_ENOMEM, "Failed to realloc PatternMatchQueue"
+                                  " rule ID array. Some signature ID matches lost");
             return 0;
         }
     }
index c221de6901f33adffe2a56e3d95a3b92efae7486..3b00d8d95e38de9667afabce9ab30acc2ae01ee5 100644 (file)
@@ -436,7 +436,7 @@ SCProfilingRuleDump(SCProfileDetectCtx *rules_ctx)
     int summary_size = sizeof(SCProfileSummary) * rules_ctx->size;
     SCProfileSummary *summary = SCMalloc(summary_size);
     if (unlikely(summary == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for profiling summary");
+        SCLogError(SC_ENOMEM, "Error allocating memory for profiling summary");
         return;
     }
 
index e74b01daf6289d80969ecd722097ab31a03b877d..b7a54ea171d04755ce04ca93fed4e8d0ee36e6d1 100644 (file)
@@ -390,7 +390,7 @@ static void ProtoNameAddEntry(const char *proto_name, const uint8_t proto_number
 
     proto_ent->name = SCStrdup(proto_name);
     if (!proto_ent->name)
-        FatalError(SC_ERR_MEM_ALLOC, "Unable to allocate memory for protocol name entries");
+        FatalError(SC_ENOMEM, "Unable to allocate memory for protocol name entries");
 
     proto_ent->number = proto_number;
 
index c98c2c72d63eb6efeee41a64a85eb8b3028aa799..0de3ef19fe1a53ed4a4d01b462999b8d679f7a33 100644 (file)
@@ -48,7 +48,7 @@ static SCRadixUserData *SCRadixAllocSCRadixUserData(uint8_t netmask, void *user)
 {
     SCRadixUserData *user_data = SCMalloc(sizeof(SCRadixUserData));
     if (unlikely(user_data == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
+        SCLogError(SC_ENOMEM, "Error allocating memory");
         return NULL;
     }
 
@@ -547,7 +547,7 @@ static SCRadixNode *SCRadixAddKey(
                                                         sizeof(uint8_t)))) == NULL) {
             SCFree(node->netmasks);
             node->netmasks = NULL;
-            SCLogError(SC_ERR_MEM_ALLOC, "Fatal error encountered in SCRadixAddKey. Mem not allocated");
+            SCLogError(SC_ENOMEM, "Fatal error encountered in SCRadixAddKey. Mem not allocated");
             return NULL;
         }
         node->netmasks = ptmp;
@@ -751,7 +751,8 @@ static SCRadixNode *SCRadixAddKey(
             if (i < node->netmask_cnt) {
                 if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                 sizeof(uint8_t))) == NULL) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Fatal error encountered in SCRadixAddKey. Mem not allocated...");
+                    SCLogError(SC_ENOMEM,
+                            "Fatal error encountered in SCRadixAddKey. Mem not allocated...");
                     SCRadixReleaseNode(inter_node, tree);
                     SCRadixReleaseNode(new_node, tree);
                     return NULL;
index 272a1f1d4fc7acd1b1a95d8016cbaeeae6ed3292..3510a5ec43ee83a7a51784513b96a13fd061a5fa 100644 (file)
@@ -64,8 +64,7 @@ char *RunmodeAutoFpCreatePickupQueuesString(int n)
 
     char *queues = SCMalloc(queues_size);
     if (unlikely(queues == NULL)) {
-        SCLogError(SC_ERR_MEM_ALLOC, "failed to alloc queues buffer: %s",
-                strerror(errno));
+        SCLogError(SC_ENOMEM, "failed to alloc queues buffer: %s", strerror(errno));
         return NULL;
     }
     memset(queues, 0x00, queues_size);
@@ -169,7 +168,8 @@ int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser,
             for (int thread = 0; thread < threads_count; thread++) {
                 char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(dev)));
                 if (unlikely(printable_threadname == NULL)) {
-                    FatalError(SC_ERR_MEM_ALLOC, "failed to alloc printable thread name: %s", strerror(errno));
+                    FatalError(SC_ENOMEM, "failed to alloc printable thread name: %s",
+                            strerror(errno));
                 }
                 snprintf(tname, sizeof(tname), "%s#%02d-%s", thread_name,
                          thread+1, visual_devname);
@@ -271,7 +271,7 @@ static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc Mod
         const char *visual_devname = LiveGetShortName(live_dev);
         char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(live_dev)));
         if (unlikely(printable_threadname == NULL)) {
-            FatalError(SC_ERR_MEM_ALLOC, "failed to alloc printable thread name: %s", strerror(errno));
+            FatalError(SC_ENOMEM, "failed to alloc printable thread name: %s", strerror(errno));
             exit(EXIT_FAILURE);
         }
 
index 4d8e61aa40aeca116004a3f881f4b2b026de8db0..dc9d3a9b7941315f845263a994aa96d4509d4074 100644 (file)
@@ -352,7 +352,7 @@ static int SetupSuppressRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid,
 
             sm = SigMatchAlloc();
             if (sm == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                 goto error;
             }
 
@@ -381,7 +381,7 @@ static int SetupSuppressRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid,
 
             sm = SigMatchAlloc();
             if (sm == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                 goto error;
             }
 
@@ -412,7 +412,7 @@ static int SetupSuppressRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid,
 
             sm = SigMatchAlloc();
             if (sm == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                 goto error;
             }
 
@@ -494,7 +494,7 @@ static int SetupThresholdRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid
 
             sm = SigMatchAlloc();
             if (sm == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                 goto error;
             }
 
@@ -534,7 +534,7 @@ static int SetupThresholdRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid
 
                 sm = SigMatchAlloc();
                 if (sm == NULL) {
-                    SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                    SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                     goto error;
                 }
 
@@ -605,7 +605,7 @@ static int SetupThresholdRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid
 
             sm = SigMatchAlloc();
             if (sm == NULL) {
-                SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+                SCLogError(SC_ENOMEM, "Error allocating SigMatch");
                 goto error;
             }