diff options
author | Angelo Mantellini <manangel@cisco.com> | 2019-01-31 18:20:48 +0100 |
---|---|---|
committer | Angelo Mantellini <manangel@cisco.com> | 2019-02-01 15:23:03 +0100 |
commit | f5a0b8a5e24cede05e15ab696f0e15257a503525 (patch) | |
tree | 8cab87196baf7ea5468cebc4002da45175d91ae8 /hicn-light/src/config/controlAddPunting.c | |
parent | bf29f9a52ffa3a1f32f700e4fd36ea53885d83aa (diff) |
[HICN24] Windows compatibility for hicn-light
Change-Id: I8e19e52c9b4ec0fcbd7344c28765f5da1937569c
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
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); |