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;
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;
}
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;
}
* 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;
}
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;
"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;
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)",
{
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;
}
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;
}
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;
}
}
/* 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);
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;
}
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);
{
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;
/* 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;
}
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;
}
// 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);
}
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);
}
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;
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?
}
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.");
}
}
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);
{
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;
{
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;
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);
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 */
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,
(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;
}
}
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);
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;
{
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");
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;
* 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;
}
{
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;
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;
{
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;
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,
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 *");
}
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;
// 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));
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;
}
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);
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);
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));
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;
}
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;
}
}
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);
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;
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 {
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
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) {
/* 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*/
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;
}
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);
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);
}
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);
}
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);
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;
}
// 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);
}
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);
}
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);
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);
}
} 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);
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);
}
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);
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);
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);
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);
}
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);
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 {
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;
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);
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;
}
}
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(
/* 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;
}
}
{
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);
} 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;
} 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;
{
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;
}
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);
}
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;
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;
}
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;
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;
}
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;
{
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;
}
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;
}
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;
}
* 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;
}
* 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;
}
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;
}
{
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));
{
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));
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;
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;
}
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;
}
{
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;
}
}
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;
}
{
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",
}
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;
}
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;
}
{
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;
}
}
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;
}
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)));
}
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)));
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");
}
}
}
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...");
}
}
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...");
}
}
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...");
}
}
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...");
}
}
#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...");
}
}
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...");
}
}
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...");
}
}
{
/* 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;
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;
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;
}
}
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;
}
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;
{
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;
}
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;
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;
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);
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);
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);
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating SigMatch");
+ SCLogError(SC_ENOMEM, "Error allocating SigMatch");
goto error;
}