From 7a57abd1f0dfcc1eeed6facf279bb0f968a6f97f Mon Sep 17 00:00:00 2001 From: Akhil498-coder Date: Fri, 28 Aug 2026 15:17:48 -0700 Subject: [PATCH 1/3] Fix string termination in node name assignment --- core/eos/core/src/graph.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/eos/core/src/graph.c b/core/eos/core/src/graph.c index 72f94aa3..5fac4d05 100644 --- a/core/eos/core/src/graph.c +++ b/core/eos/core/src/graph.c @@ -21,6 +21,7 @@ EosResult eos_graph_add_node(EosGraph *g, const char *name, EosNodeType type, int id = g->node_count; EosNode *n = &g->nodes[id]; strncpy(n->name, name, EOS_MAX_NAME - 1); + n->name[EOS_MAX_NAME-1] = '\0'; n->type = type; n->build_type = build_type; n->status = EOS_NODE_PENDING; From 9d5831ee7807a22da29e1c626f93e781bb22da2a Mon Sep 17 00:00:00 2001 From: Akhil498-coder Date: Fri, 28 Aug 2026 15:36:46 -0700 Subject: [PATCH 2/3] Implement test for max-length node name in graph Added a test for maximum-length node names in the graph. --- core/eos/tests/test_graph.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/core/eos/tests/test_graph.c b/core/eos/tests/test_graph.c index 40a16bc9..4e613be8 100644 --- a/core/eos/tests/test_graph.c +++ b/core/eos/tests/test_graph.c @@ -52,6 +52,39 @@ static void test_graph_add_nodes(void) { ASSERT(g.node_count == 3, "graph has 3 nodes"); } +static void test_graph_max_length_node_name(void) { + printf("test_graph_max_length_node_name:\n"); + + EosGraph g; + eos_graph_init(&g); + + char name[EOS_MAX_NAME]; + + /* Create a name that fills the buffer except for the null terminator. */ + memset(name, 'A', EOS_MAX_NAME - 1); + name[EOS_MAX_NAME - 1] = '\0'; + + int id; + EosResult r = eos_graph_add_node( + &g, + name, + EOS_NODE_PACKAGE, + EOS_BUILD_CMAKE, + &id + ); + + ASSERT(r == EOS_OK, "maximum-length node name can be added"); + + ASSERT( + g.nodes[id].name[EOS_MAX_NAME - 1] == '\0', + "node name is null terminated" + ); + + ASSERT( + eos_graph_find_node(&g, name) == id, + "maximum-length node name can be found" + ); +} static void test_graph_find_node(void) { printf("test_graph_find_node:\n"); @@ -168,6 +201,7 @@ int main(void) { test_graph_init(); test_graph_add_nodes(); test_graph_find_node(); + test_graph_max_length_node_name(); test_topological_sort_linear(); test_topological_sort_diamond(); test_cycle_detection(); From 8e5270910fa5bcaa1ae7e6ab44cd742b5e1f70d8 Mon Sep 17 00:00:00 2001 From: Akhil498-coder Date: Fri, 28 Aug 2026 15:56:47 -0700 Subject: [PATCH 3/3] Initialize node name with non-zero data in test Added non-zero data initialization for node name to detect missing null terminator. --- core/eos/tests/test_graph.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/eos/tests/test_graph.c b/core/eos/tests/test_graph.c index 4e613be8..a93afc9b 100644 --- a/core/eos/tests/test_graph.c +++ b/core/eos/tests/test_graph.c @@ -64,6 +64,13 @@ static void test_graph_max_length_node_name(void) { memset(name, 'A', EOS_MAX_NAME - 1); name[EOS_MAX_NAME - 1] = '\0'; + /* + * Fill the destination with non-zero data so the test can detect + * a missing null terminator even though eos_graph_init() zeroes + * the graph initially. + */ + memset(g.nodes[0].name, 'X', EOS_MAX_NAME); + int id; EosResult r = eos_graph_add_node( &g, @@ -85,7 +92,6 @@ static void test_graph_max_length_node_name(void) { "maximum-length node name can be found" ); } - static void test_graph_find_node(void) { printf("test_graph_find_node:\n"); EosGraph g;