From 50e85abc25f617ac5a5e1db678a2dc2c6da964bc Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 13 Apr 2024 22:40:46 +0300 Subject: [PATCH 1/2] isisd: Fix compile warning with `-Wformat-truncation` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isisd/isis_spf.c: In function ‘show_isis_route_common’: isisd/isis_spf.c:3034:39: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] snprintf(key, sizeof(key), "level-%d", level); ^~ isisd/isis_spf.c:3034:32: note: directive argument in the range [1, 2147483646] snprintf(key, sizeof(key), "level-%d", level); ^~~~~~~~~~ Signed-off-by: Donatas Abraitis --- isisd/isis_spf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 36986a19c5..294c03def1 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -2908,7 +2908,7 @@ static void show_isis_route_common(struct vty *vty, int levels, struct isis_spftree *spftree; struct listnode *node; struct isis_area *area; - char key[8]; + char key[18]; if (!isis->area_list || isis->area_list->count == 0) return; From f003ccf16b141836758183a3f9f984f970289a7a Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 13 Apr 2024 22:41:43 +0300 Subject: [PATCH 2/2] ospfd: Fix compile warning with `-Wformat-truncation` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ospfd/ospf_sr.c: In function ‘show_sr_node.part.5’: ospfd/ospf_sr.c:2745:32: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] snprintf(tmp, sizeof(tmp), "%u", i); ^~ ospfd/ospf_sr.c:2745:31: note: directive argument in the range [0, 2147483646] snprintf(tmp, sizeof(tmp), "%u", i); Signed-off-by: Donatas Abraitis --- ospfd/ospf_sr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index e26fe6f53a..198309c1ef 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -2740,9 +2740,9 @@ static void show_sr_node(struct vty *vty, struct json_object *json, if (srn->algo[i] == SR_ALGORITHM_UNSET) continue; json_obj = json_object_new_object(); - char tmp[2]; + char tmp[12]; - snprintf(tmp, sizeof(tmp), "%u", i); + snprintf(tmp, sizeof(tmp), "%d", i); json_object_string_add(json_obj, tmp, srn->algo[i] == SR_ALGORITHM_SPF ? "SPF"