summaryrefslogtreecommitdiffstats
path: root/hicn-light/src/config/controlAddRoute.c
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/config/controlAddRoute.c')
-rw-r--r--hicn-light/src/config/controlAddRoute.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hicn-light/src/config/controlAddRoute.c b/hicn-light/src/config/controlAddRoute.c
index c5ddab523..27aae4019 100644
--- a/hicn-light/src/config/controlAddRoute.c
+++ b/hicn-light/src/config/controlAddRoute.c
@@ -20,7 +20,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
#include <parc/assert/parc_Assert.h>
@@ -97,7 +96,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
}
const char *prefixStr = parcList_GetAtIndex(args, 3);
- char addr[strlen(prefixStr) + 1];
+ char *addr = (char *)malloc((strlen(prefixStr) + 1) * sizeof(char));
// separate address and len
char *slash;
@@ -111,6 +110,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
if (len == 0) {
printf("ERROR: a prefix can not be of length 0\n");
+ free(addr);
return CommandReturn_Failure;
}
@@ -123,6 +123,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addRouteCommand);
+ free(addr);
return CommandReturn_Failure;
}
addRouteCommand->addressType = ADDR_INET;
@@ -130,15 +131,19 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addRouteCommand);
+ free(addr);
return CommandReturn_Failure;
}
addRouteCommand->addressType = ADDR_INET6;
} else {
printf("Error: %s is not a valid network address \n", addr);
parcMemory_Deallocate(&addRouteCommand);
+ free(addr);
return CommandReturn_Failure;
}
+ free(addr);
+
// Fill remaining payload fields
addRouteCommand->len = len;
addRouteCommand->cost = (uint16_t)cost;