/* Need to dup the key for tokenization... */
char *tokstr = SCStrdup(key);
+ if (tokstr == NULL) {
+ return NULL;
+ }
#if defined(__WIN32) || defined(_WIN32)
token = strtok(tokstr, ".");
}
else {
char *tokstr = SCStrdup(name);
+ if (tokstr == NULL) {
+ return 0;
+ }
#if defined(__WIN32) || defined(_WIN32)
token = strtok(tokstr, ".");
#else
strlcat(path, file, path_len);
} else {
path = SCStrdup(file);
+ if (path == NULL)
+ return NULL;
}
} else {
path = SCStrdup(file);
+ if (path == NULL)
+ return NULL;
}
return path;
}
char *mask = NULL;
int r = 0;
+ if (ipdup == NULL)
+ return -1;
SCLogDebug("str %s", str);
/* first handle 'any' */
char *mask = NULL;
int r = 0;
+ if (ipdup == NULL)
+ return -1;
SCLogDebug("str %s", str);
/* first handle 'any' */
char *port2 = NULL;
DetectPort *dp = NULL;
+ if (portdup == NULL) {
+ return NULL;
+ }
dp = DetectPortInit();
if (dp == NULL)
goto error;
goto error;
orig = SCStrdup((char*)str_ptr);
- tmp_str=orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str=orig;
/* Let's see if we need to scape "'s */
if (tmp_str[0] == '"')
}
orig = SCStrdup((char*) str_ptr[i]);
- tmp_str = orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str = orig;
/* Let's see if we need to scape "'s */
if (tmp_str[0] == '"') {
goto error;
orig = SCStrdup((char*)str_ptr);
- tmp_str=orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str=orig;
/* Let's see if we need to scape "'s */
if (tmp_str[0] == '"')
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- tmp_str=orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str=orig;
/* Let's see if we need to escape "'s */
if (tmp_str[0] == '"') {
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- tmp_str=orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str=orig;
/* Let's see if we need to escape "'s */
if (tmp_str[0] == '"')
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- tmp_str=orig;
- if (tmp_str == NULL) {
+ if (orig == NULL) {
goto error;
}
+ tmp_str=orig;
/* Let's see if we need to escape "'s */
if (tmp_str[0] == '"')
strlcat(path, sig_file, path_len);
} else {
path = SCStrdup(sig_file);
+ if (path == NULL)
+ return NULL;
}
} else {
path = SCStrdup(sig_file);
+ if (path == NULL)
+ return NULL;
}
return path;
}
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
+ if (thread_name == NULL) {
+ printf("ERROR: Can't allocate thread name\n");
+ exit(EXIT_FAILURE);
+ }
SCLogDebug("Assigning %s affinity to cpu %u", thread_name, cpu);
ThreadVars *tv_detect_ncpu =
for (feed=0; feed < feed_count; feed++) {
snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
feedName = SCStrdup(tname);
+ if (feedName == NULL) {
+ fprintf(stderr, "ERROR: Alloc feed name\n");
+ exit(EXIT_FAILURE);
+ }
snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
threadName = SCStrdup(tname);
+ if (threadName == NULL) {
+ fprintf(stderr, "ERROR: Alloc thread name\n");
+ exit(EXIT_FAILURE);
+ }
+
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
outQueueName = SCStrdup(tname);
+ if (outQueueName == NULL) {
+ fprintf(stderr, "ERROR: Alloc output queue name\n");
+ exit(EXIT_FAILURE);
+ }
/* create the threads */
ThreadVars *tv_napatechFeed = TmThreadCreatePacketHandler(threadName,"packetpool",
{
snprintf(tname, sizeof(tname),"Detect%"PRIu16"/%"PRIu16,feed,detect++);
threadName = SCStrdup(tname);
+ if (threadName == NULL) {
+ fprintf(stderr, "ERROR: can not strdup thread name\n");
+ exit(EXIT_FAILURE);
+ }
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
inQueueName = SCStrdup(tname);
+ if (inQueueName == NULL) {
+ fprintf(stderr, "ERROR: can not strdup in queue name\n");
+ exit(EXIT_FAILURE);
+ }
ThreadVars *tv_detect = TmThreadCreatePacketHandler(threadName,
inQueueName,"simple",
for (feed=0; feed < feed_count; feed++) {
snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
feedName = SCStrdup(tname);
+ if (feedName == NULL) {
+ fprintf(stderr, "ERROR: can not strdup feed name\n");
+ exit(EXIT_FAILURE);
+ }
snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
threadName = SCStrdup(tname);
+ if (threadName == NULL) {
+ fprintf(stderr, "ERROR: can not strdup in thread name\n");
+ exit(EXIT_FAILURE);
+ }
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
outQueueName = SCStrdup(tname);
+ if (outQueueName == NULL) {
+ fprintf(stderr, "ERROR: can not strdup out queue name\n");
+ exit(EXIT_FAILURE);
+ }
/* create the threads */
ThreadVars *tv_napatechFeed = TmThreadCreatePacketHandler(threadName,"packetpool",
snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1);
char *thread_name = SCStrdup(tname);
+ if (thread_name == NULL) {
+ printf("ERROR: Can not strdup thread name\n");
+ exit(EXIT_FAILURE);
+ }
SCLogDebug("Assigning %s affinity to cpu %u", thread_name, cpu);
ThreadVars *tv_detect_ncpu =
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
+ if (thread_name == NULL) {
+ printf("ERROR: Can not strdup thread name\n");
+ exit(EXIT_FAILURE);
+ }
SCLogDebug("Assigning %s affinity to cpu %u", thread_name, cpu);
ThreadVars *tv_detect_ncpu =
SCLogWarning(SC_ERR_RUNMODE, "'worker' mode have been renamed "
"to 'workers', please modify your setup.");
custom_mode = SCStrdup("workers");
+ if (unlikely(custom_mode == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup custom mode");
+ exit(EXIT_FAILURE);
+ }
}
}
/* Export the custom mode */
active_runmode = SCStrdup(custom_mode);
+ if (unlikely(active_runmode == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup active mode");
+ exit(EXIT_FAILURE);
+ }
mode->RunModeFunc(de_ctx);
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
char *thread_name = SCStrdup(tname);
+ if (unlikely(thread_name == NULL)) {
+ printf("ERROR: Can't create thread name failed\n");
+ exit(EXIT_FAILURE);
+ }
ThreadVars *tv_receivenfq =
TmThreadCreatePacketHandler(thread_name,
"packetpool", "packetpool",
snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1);
char *thread_name = SCStrdup(tname);
+ if (unlikely(thread_name == NULL)) {
+ printf("ERROR: thead name creation failed\n");
+ exit(EXIT_FAILURE);
+ }
SCLogDebug("Assigning %s affinity", thread_name);
ThreadVars *tv_detect_ncpu =
snprintf(tname, sizeof(tname), "Verdict%"PRIu16, i);
char *thread_name = SCStrdup(tname);
+ if (unlikely(thread_name == NULL)) {
+ printf("ERROR: thead name creation failed\n");
+ exit(EXIT_FAILURE);
+ }
ThreadVars *tv_verdict =
TmThreadCreatePacketHandler(thread_name,
"verdict-queue", "simple",
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
char *thread_name = SCStrdup(tname);
-
+ if (unlikely(thread_name == NULL)) {
+ printf("ERROR: thead name creation failed\n");
+ exit(EXIT_FAILURE);
+ }
ThreadVars *tv_receive =
TmThreadCreatePacketHandler(thread_name,
"packetpool", "packetpool",
snprintf(tname, sizeof(tname), "Verdict%"PRIu16, i);
char *thread_name = SCStrdup(tname);
+ if (unlikely(thread_name == NULL)) {
+ SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
+ exit(EXIT_FAILURE);
+ }
ThreadVars *tv_verdict =
TmThreadCreatePacketHandler(thread_name,
"verdict-queue", "simple",
snprintf(tname, sizeof(tname), "Worker-Q%s", cur_queue);
char *thread_name = SCStrdup(tname);
+ if (unlikely(thread_name == NULL)) {
+ SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
+ exit(EXIT_FAILURE);
+ }
tv = TmThreadCreatePacketHandler(thread_name,
"packetpool", "packetpool",
"packetpool", "packetpool",