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/controlRemoveRoute.c | |
parent | e8fabe3f6313a3b9050fe16458e4714d9dce426e (diff) | |
parent | f5a0b8a5e24cede05e15ab696f0e15257a503525 (diff) |
Merge "[HICN24] Windows compatibility for hicn-light"
Diffstat (limited to 'hicn-light/src/config/controlRemoveRoute.c')
-rw-r--r-- | hicn-light/src/config/controlRemoveRoute.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hicn-light/src/config/controlRemoveRoute.c b/hicn-light/src/config/controlRemoveRoute.c index b9b4ed1e4..f654718f8 100644 --- a/hicn-light/src/config/controlRemoveRoute.c +++ b/hicn-light/src/config/controlRemoveRoute.c @@ -20,10 +20,7 @@ #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#include <strings.h> - #include <parc/assert/parc_Assert.h> - #include <parc/algol/parc_List.h> #include <parc/algol/parc_Memory.h> #include <parc/algol/parc_Network.h> @@ -90,7 +87,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, } const char *prefixStr = parcList_GetAtIndex(args, 3); - char addr[strlen(prefixStr) + 1]; + char *addr = (char *)malloc(sizeof(char) * (strlen(prefixStr) + 1)); // separate address and len char *slash; @@ -104,6 +101,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len == 0) { printf("ERROR: a prefix can not be of length 0\n"); + free(addr); return CommandReturn_Failure; } @@ -116,6 +114,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len > 32) { printf("ERROR: exceeded INET mask length, max=32\n"); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } removeRouteCommand->addressType = ADDR_INET; @@ -124,15 +123,18 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser, if (len > 128) { printf("ERROR: exceeded INET6 mask length, max=128\n"); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } removeRouteCommand->addressType = ADDR_INET6; } else { printf("Error: %s is not a valid network address \n", addr); parcMemory_Deallocate(&removeRouteCommand); + free(addr); return CommandReturn_Failure; } + free(addr); // Fill remaining payload fields removeRouteCommand->len = len; strcpy(removeRouteCommand->symbolicOrConnid, symbolicOrConnid); |