linux/hostdisk: use strncpy instead of strlcpy

strlcpy is not available on Linux as part of standard libraries.
It probably is not worth extra configure checks espicially as we
need to handle missing function anyway.
This commit is contained in:
Andrei Borzenkov 2015-01-27 20:00:23 +03:00
parent 9ee5ae1fae
commit 7ba137f628
1 changed files with 4 additions and 2 deletions

View File

@ -376,7 +376,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
part_start = grub_partition_get_start (disk->partition);
strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev));
strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
dev[sizeof(dev) - 1] = '\0';
if (disk->partition
&& strncmp (dev, "/dev/", 5) == 0)
{
@ -439,7 +440,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
if (*max == 0)
*max = ~0ULL;
is_partition = 0;
strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev));
strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
dev[sizeof(dev) - 1] = '\0';
goto reopen;
}
sector -= part_start;