From: Aschref Ben Thabet <aschref.ben-tha...@embedded-brains.de> Replace strncpy() with memcpy() to guarantee a safe copying of characters. --- cpukit/libblock/src/bdpart-mount.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/cpukit/libblock/src/bdpart-mount.c b/cpukit/libblock/src/bdpart-mount.c index cfc08ead30..dd4c09c59e 100644 --- a/cpukit/libblock/src/bdpart-mount.c +++ b/cpukit/libblock/src/bdpart-mount.c @@ -54,7 +54,7 @@ rtems_status_code rtems_bdpart_mount( if (logical_disk_name == NULL) { return RTEMS_NO_MEMORY; } - strncpy( logical_disk_name, disk_name, disk_name_size); + memcpy(logical_disk_name, disk_name, disk_name_size); /* Get disk file name */ if (disk_file_name != NULL) { @@ -71,9 +71,8 @@ rtems_status_code rtems_bdpart_mount( esc = RTEMS_NO_MEMORY; goto cleanup; } - strncpy( mount_point, mount_base, mount_base_size); - mount_point [mount_base_size] = '/'; - strncpy( mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size); + memcpy(mount_point, mount_base, mount_base_size); + memcpy(mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size); /* Markers */ logical_disk_marker = logical_disk_name + disk_name_size; @@ -89,7 +88,7 @@ rtems_status_code rtems_bdpart_mount( } /* Create mount point */ - strncpy( mount_marker, logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE); + memcpy( mount_marker, logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE); rv = rtems_mkdir( mount_point, S_IRWXU | S_IRWXG | S_IRWXO); if (rv != 0) { esc = RTEMS_IO_ERROR; @@ -148,9 +147,8 @@ rtems_status_code rtems_bdpart_unmount( esc = RTEMS_NO_MEMORY; goto cleanup; } - strncpy( mount_point, mount_base, mount_base_size); - mount_point [mount_base_size] = '/'; - strncpy( mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size); + memcpy(mount_point, mount_base, mount_base_size); + memcpy( mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size); /* Marker */ mount_marker = mount_point + mount_base_size + 1 + disk_file_name_size; -- 2.26.2 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel