From efdea6fd8ad376c5ae591cc0ede35c636ad4e9ae Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Thu, 22 Sep 2022 09:44:07 +0100 Subject: [PATCH] DynamicDNS: Fix a crash when increasing the number of services (cherry picked from commit 942b7251dd57196981c2e841b355dcd8642f3dcc) --- dmtree/tr181/dynamicdns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dmtree/tr181/dynamicdns.c b/dmtree/tr181/dynamicdns.c index 896c01f3..dbcc85b0 100644 --- a/dmtree/tr181/dynamicdns.c +++ b/dmtree/tr181/dynamicdns.c @@ -41,7 +41,7 @@ static void update_supported_services(void) { struct uci_section *s = NULL; char *service_name = NULL; - char supported_services[1024] = {0}; + char supported_services[2048] = {0}; unsigned pos = 0; supported_services[0] = 0; @@ -49,6 +49,9 @@ static void update_supported_services(void) uci_path_foreach_sections(bbfdm, "dmmap_ddns", "server", s) { dmuci_get_value_by_section_string(s, "service_name", &service_name); + if ((sizeof(supported_services) - pos) < DM_STRLEN(service_name)) + break; + pos += snprintf(&supported_services[pos], sizeof(supported_services) - pos, "%s,", service_name); }