]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
linux/hostdisk: use strncpy instead of strlcpy
authorAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 27 Jan 2015 17:00:23 +0000 (20:00 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 27 Jan 2015 17:00:23 +0000 (20:00 +0300)
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

index 75cb8f55dbe454fa0f1fc9f6aab76d22cd128e29..06179fca72587d23b5c4d6cfc9f2fe58b1aa5b72 100644 (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;