From 8ecb55c47cc9895b9c0725e9a41954c1918352eb Mon Sep 17 00:00:00 2001 From: burneykb <burneykb@iastate.edu> Date: Mon, 27 Mar 2017 03:46:44 -0500 Subject: [PATCH] bug squashing in addnodes --- groundStation/src/cli/cli_nodes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/groundStation/src/cli/cli_nodes.c b/groundStation/src/cli/cli_nodes.c index 555e2e71d..5dc2d18a1 100644 --- a/groundStation/src/cli/cli_nodes.c +++ b/groundStation/src/cli/cli_nodes.c @@ -73,6 +73,7 @@ int cli_getnodes(struct backend_conn * conn, int argc, char ** argv) { int cli_addnode(struct backend_conn * conn, int argc, char ** argv) { struct frontend_node_data node_data; + int needHelp = 0; if ((needHelp = help_check(argc, argv))) { @@ -87,8 +88,12 @@ int cli_addnode(struct backend_conn * conn, int argc, char ** argv) { return 1; } + if ((node_data.name = (char *)malloc((*node_data.name) * strlen(argv[2]))) == NULL) { + return 1; + } + node_data.type = atoi(argv[1]); - strncpy(node_data.name, argv[2], 512/* this value matches the max space of name */ ); + strncpy(node_data.name, argv[2], strlen(argv[2])); if (frontend_addnode(conn, &node_data)) { return 1; -- GitLab