summaryrefslogtreecommitdiffstats
path: root/hicn-light/src/config/controlAddPunting.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/config/controlAddPunting.c')
-rw-r--r--hicn-light/src/config/controlAddPunting.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hicn-light/src/config/controlAddPunting.c b/hicn-light/src/config/controlAddPunting.c
index bd87e517c..13d00b7e0 100644
--- a/hicn-light/src/config/controlAddPunting.c
+++ b/hicn-light/src/config/controlAddPunting.c
@@ -20,7 +20,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
#include <parc/assert/parc_Assert.h>
@@ -93,7 +92,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
}
const char *prefixStr = parcList_GetAtIndex(args, _indexPrefix);
- char addr[strlen(prefixStr) + 1];
+ char *addr = (char *)malloc((strlen(prefixStr) + 1) * sizeof(char));
// separate address and len
char *slash;
@@ -107,6 +106,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
if (len == 0) {
printf("ERROR: a prefix can not be of length 0\n");
+ free(addr);
return CommandReturn_Failure;
}
@@ -119,6 +119,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addPuntingCommand);
+ free(addr);
return CommandReturn_Failure;
}
addPuntingCommand->addressType = ADDR_INET;
@@ -126,15 +127,19 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addPuntingCommand);
+ free(addr);
return CommandReturn_Failure;
}
addPuntingCommand->addressType = ADDR_INET6;
} else {
printf("Error: %s is not a valid network address \n", addr);
parcMemory_Deallocate(&addPuntingCommand);
+ free(addr);
return CommandReturn_Failure;
}
+ free(addr);
+
// Fill remaining payload fields
addPuntingCommand->len = len;
strcpy(addPuntingCommand->symbolicOrConnid, symbolicOrConnid);