grub2/0259-linux-hostdisk-use-strncpy-instead-of-strlcpy.patch

40 lines
1.5 KiB
Diff
Raw Normal View History

From 7ba137f6286dcd17a1104f1dfc6eb1f58c5ef743 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <arvidjaar@gmail.com>
Date: Tue, 27 Jan 2015 20:00:23 +0300
Subject: [PATCH 259/506] 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.
---
grub-core/osdep/linux/hostdisk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
index 75cb8f5..06179fc 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;
--
2.4.3