vppinfra: avoid string truncation errors by some gcc versions 61/43361/2
authorDamjan Marion <[email protected]>
Mon, 30 Jun 2025 13:53:21 +0000 (15:53 +0200)
committerDamjan Marion <[email protected]>
Tue, 1 Jul 2025 10:44:18 +0000 (10:44 +0000)
Type: fix
Change-Id: If33251e1eac7e437ae803363d960896da02ae567
Signed-off-by: Damjan Marion <[email protected]>
src/vppinfra/devicetree.c

index 309308c..5d14231 100644 (file)
@@ -118,7 +118,9 @@ clib_dt_read_from_sysfs (clib_dt_main_t *dm)
 
                  if (read (fd, p->data, st.st_size) == st.st_size)
                    {
-                     strncpy (p->name, e->d_name, sizeof (p->name));
+                     snprintf (p->name, sizeof (p->name), "%.*s",
+                               (int) sizeof (p->name) - 1, e->d_name);
+
                      p->size = st.st_size;
                      vec_add1 (n->properties, p);
                      if (strncmp ("name", p->name, 5) == 0)