* */
OutputCtx *LogHttpLogInitCtx(ConfNode *conf)
{
- LogFileCtx* file_ctx=LogFileNewCtx();
-
- if(file_ctx == NULL)
- {
- SCLogError(SC_ERR_HTTP_LOG_GENERIC, "LogHttpLogInitCtx: Couldn't "
- "create new file_ctx");
+ LogFileCtx* file_ctx = LogFileNewCtx();
+ if(file_ctx == NULL) {
+ SCLogError(SC_ERR_HTTP_LOG_GENERIC, "couldn't create new file_ctx");
return NULL;
}
return NULL;
}
- LogHttpFileCtx *httplog_ctx = SCCalloc(1, sizeof(LogHttpFileCtx));
- if (httplog_ctx == NULL)
+ LogHttpFileCtx *httplog_ctx = SCMalloc(sizeof(LogHttpFileCtx));
+ if (httplog_ctx == NULL) {
+ LogFileFreeCtx(file_ctx);
return NULL;
+ }
+ memset(httplog_ctx, 0x00, sizeof(LogHttpFileCtx));
+
httplog_ctx->file_ctx = file_ctx;
+
const char *extended = ConfNodeLookupChildValue(conf, "extended");
if (extended == NULL) {
httplog_ctx->flags |= LOG_HTTP_DEFAULT;
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (output_ctx == NULL) {
+ LogFileFreeCtx(file_ctx);
+ SCFree(httplog_ctx);
return NULL;
+ }
+
output_ctx->data = httplog_ctx;
output_ctx->DeInit = LogHttpLogDeInitCtx;
return 0;
}
+static void PcapFileNameFree(PcapFileName *pf) {
+ if (pf != NULL) {
+ if (pf->filename != NULL) {
+ SCFree(pf->filename);
+ }
+ if (pf->dirname != NULL) {
+ SCFree(pf->dirname);
+ }
+ SCFree(pf);
+ }
+}
+
/**
* \brief Function to rotate pcaplog file
*
"failed to remove log file %s: %s",
pf->filename, strerror( errno ));
TAILQ_REMOVE(&pcap_file_list, pf, next);
- if (pf != NULL)
- free(pf);
+ PcapFileNameFree(pf);
return -1;
}
else {
"failed to remove sguil log %s: %s",
pf->dirname, strerror( errno ));
TAILQ_REMOVE(&pcap_file_list, pf, next);
- if (pf != NULL)
- free(pf);
+ PcapFileNameFree(pf);
return -1;
}
}
}
+
TAILQ_REMOVE(&pcap_file_list, pf, next);
- if (pf != NULL)
- free(pf);
+ PcapFileNameFree(pf);
pl->file_cnt--;
}
memset(&ts, 0x00, sizeof(struct timeval));
TimeGet(&ts);
-
/* Place to store the name of our PCAP file */
PcapFileName *pf = SCMalloc(sizeof(PcapFileName));
if (pf == NULL) {
#endif
if ((pf->dirname = SCStrdup(dirfull)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for directory name");
- return -1;
- }
-
- if (strlen(pf->dirname) == 0) {
- SCFree(pf->dirname);
- return -1;
+ goto error;
}
if (pl->timestamp_format == TS_FORMAT_SEC) {
if ((pf->filename = SCStrdup(pl->filename)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory. For filename");
- return -1;
+ goto error;
}
- SCLogDebug("Opening pcap file log %s\n", pf->filename);
+ SCLogDebug("Opening pcap file log %s", pf->filename);
TAILQ_INSERT_TAIL(&pcap_file_list, pf, next);
return 0;
+
+error:
+ PcapFileNameFree(pf);
+ return -1;
}
intmax_t value;
int boolval;
- if (iface == NULL) {
+ if (aconf == NULL) {
return NULL;
}
- if (aconf == NULL) {
+ if (iface == NULL) {
+ SCFree(aconf);
return NULL;
}
+
strlcpy(aconf->iface, iface, sizeof(aconf->iface));
aconf->threads = 1;
SC_ATOMIC_INIT(aconf->ref);
aconf->cluster_type = PACKET_FANOUT_CPU;
} else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype);
+ SCFree(aconf);
return NULL;
}
char *tmpctype;
intmax_t value;
- if (iface == NULL) {
+ if (aconf == NULL) {
return NULL;
}
- if (aconf == NULL) {
+ if (iface == NULL) {
+ SCFree(aconf);
return NULL;
}
+
strlcpy(aconf->iface, iface, sizeof(aconf->iface));
aconf->buffer_size = 0;
cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
#endif
- if (iface == NULL) {
+ if (pfconf == NULL) {
return NULL;
}
- if (pfconf == NULL) {
+ if (iface == NULL) {
+ SCFree(pfconf);
return NULL;
}
+
strlcpy(pfconf->iface, iface, sizeof(pfconf->iface));
pfconf->threads = 1;
pfconf->cluster_id = 1;
pfconf->ctype = (cluster_type)tmpctype;
} else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype);
+ SCFree(pfconf);
return NULL;
}
#endif
char *bpf_filter = NULL;
#endif /* HAVE_PFRING_SET_BPF_FILTER */
- if (iface == NULL) {
+ if (pfconf == NULL) {
return NULL;
}
- if (pfconf == NULL) {
+ if (iface == NULL) {
+ SCFree(pfconf);
return NULL;
}
+
memset(pfconf, 0, sizeof(PfringIfaceConfig));
strlcpy(pfconf->iface, iface, sizeof(pfconf->iface));
pfconf->threads = 1;
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,
"invalid cluster-type %s",
tmpctype);
+ SCFree(pfconf);
return NULL;
}
}
ptv->livedev = LiveGetDevice(ptv->iface);
if (ptv->livedev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device");
+ SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
ptv->livedev = LiveGetDevice(pcapconfig->iface);
if (ptv->livedev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device");
+ SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
return tv;
error:
- printf("ERROR: failed to setup a thread.\n");
+ SCLogError(SC_ERR_THREAD_CREATE, "failed to setup a thread");
+
+ if (tv != NULL)
+ SCFree(tv);
return NULL;
}
ptrmem = malloc((a)); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
- uintmax_t size = (uintmax_t)(a); \
+ uintmax_t scmalloc_size_ = (uintmax_t)(a); \
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \
- "to allocate %"PRIuMAX" bytes", strerror(errno), size); \
+ "to allocate %"PRIuMAX" bytes", strerror(errno), scmalloc_size_); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \