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

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); 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 if (disk->partition
&& strncmp (dev, "/dev/", 5) == 0) && 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) if (*max == 0)
*max = ~0ULL; *max = ~0ULL;
is_partition = 0; 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; goto reopen;
} }
sector -= part_start; sector -= part_start;