summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeepti Kulkarni <deepti@vyatta.com>2011-12-21 10:15:09 -0800
committerDeepti Kulkarni <deepti@vyatta.com>2011-12-21 10:15:09 -0800
commited1bdeea5e608d0c4005bb61d89636fc73bc3243 (patch)
tree06a6cfd21b74878127d481461f364187879e2317
parent1faa120cfe87b794a2cad4742ee8fe089ef8cca0 (diff)
downloadvyatta-conntrack-ed1bdeea5e608d0c4005bb61d89636fc73bc3243.tar.gz
vyatta-conntrack-ed1bdeea5e608d0c4005bb61d89636fc73bc3243.zip
Corrected incorrect malloc.
-rw-r--r--src/vyatta-conntrack-logging.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vyatta-conntrack-logging.c b/src/vyatta-conntrack-logging.c
index d31e598..9c05869 100644
--- a/src/vyatta-conntrack-logging.c
+++ b/src/vyatta-conntrack-logging.c
@@ -6,6 +6,8 @@ Usage: ./vyatta-conntrack-logging
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
@@ -126,7 +128,6 @@ void daemonize()
int main(int argc, char *argv[])
{
- FILE *logfile;
int other=0;
int i, pid;
char *conn="conntrack -E";
@@ -173,7 +174,7 @@ int main(int argc, char *argv[])
if (other == 1) {
snprintf(temp_cmd, sizeof (cmd) - length, "%s%s%s%s%s%s%s%s", " -e ",
argv[i+1], " -o id", " -b %d", " | ", fother, " | ", logger);
- cmds[pcounter] = malloc(strlen+1);
+ cmds[pcounter] = malloc(strlen(cmd)+1);
strcpy(cmds[pcounter],cmd);
pcounter++;
} else if ((strncmp(argv[i-1], "tcp",strlen(argv[i-1]))==0) &&
@@ -182,7 +183,7 @@ int main(int argc, char *argv[])
} else {
snprintf(temp_cmd, sizeof (cmd) - length, "%s%s%s%s%s%s", " -e ",
argv[i+1], " -o id", " -b %d", " | ", logger);
- cmds[pcounter] = malloc(strlen+1);
+ cmds[pcounter] = malloc(strlen(cmd)+1);
strcpy(cmds[pcounter],cmd);
pcounter++;
}
@@ -208,7 +209,7 @@ int main(int argc, char *argv[])
strlen(argv[i+1])) == 0)) {
snprintf(temp_cmd, sizeof (cmd) - length, "%s%s%s%s%s%s", " --state ",
argv[i+1], " -o id", " -b %d", " | ", logger);
- cmds[pcounter] = malloc(strlen+1);
+ cmds[pcounter] = malloc(strlen(cmd)+1);
strcpy(cmds[pcounter],cmd);
pcounter++;
length = strlen (cmd);