[PATCH] cpukit/libblock/bdpart-register.c: Fix string truncation warning.

Aschref Ben-Thabet aschref.ben-thabet at embedded-brains.de
Tue Sep 15 09:09:02 UTC 2020


From: Aschref Ben Thabet <aschref.ben-thabet at embedded-brains.de>

Replace strncpy() with memcpy() to guarantee a safe copying of
characters.
---
 cpukit/libblock/src/bdpart-register.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libblock/src/bdpart-register.c b/cpukit/libblock/src/bdpart-register.c
index 9956e61a68..8a1de6135e 100644
--- a/cpukit/libblock/src/bdpart-register.c
+++ b/cpukit/libblock/src/bdpart-register.c
@@ -38,7 +38,7 @@ static char *create_logical_disk_name( const char *disk_name, char **marker)
   char *logical_disk_name = malloc( disk_name_size + RTEMS_BDPART_NUMBER_SIZE);
 
   if (logical_disk_name != NULL) {
-    strncpy( logical_disk_name, disk_name, disk_name_size);
+    memcpy( logical_disk_name, disk_name, disk_name_size);
     *marker = logical_disk_name + disk_name_size;
   }
 
-- 
2.26.2



More information about the devel mailing list