diff options
author | Luca Muscariello <lumuscar+fdio@cisco.com> | 2019-02-01 20:00:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2019-02-01 20:00:21 +0000 |
commit | 79f9c336d9d8af63e322e3c52f09fec3d7cb3c2b (patch) | |
tree | 7674e218ee813ff7aec6868ab86a1dd6c40af28f /hicn-light/src/config/controlAddPunting.c | |
parent | e8fabe3f6313a3b9050fe16458e4714d9dce426e (diff) | |
parent | f5a0b8a5e24cede05e15ab696f0e15257a503525 (diff) |
Merge "[HICN24] Windows compatibility for hicn-light"
Diffstat (limited to 'hicn-light/src/config/controlAddPunting.c')
-rw-r--r-- | hicn-light/src/config/controlAddPunting.c | 9 |
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); |