From: Andrei Borzenkov Date: Tue, 27 Jan 2015 17:00:23 +0000 (+0300) Subject: linux/hostdisk: use strncpy instead of strlcpy X-Git-Tag: 2.02-beta3~463 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ba137f6286dcd17a1104f1dfc6eb1f58c5ef743;p=thirdparty%2Fgrub.git 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. --- diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 75cb8f55d..06179fca7 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -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;