]> git.proxmox.com Git - grub2.git/commitdiff
grub-install-common: avoid out of bound access when read failed
authorAndrei Borzenkov <arvidjaar@gmail.com>
Fri, 28 Nov 2014 17:45:27 +0000 (20:45 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Fri, 28 Nov 2014 17:45:27 +0000 (20:45 +0300)
Check that modinfo.sh could be read successfully; abort on error. Avoids
potential out-of-bound array access.

CID: 73819

ChangeLog
util/grub-install-common.c

index 930ceb20c0699e3d5f7732306ffdd18dee01c397..e46b9995be487af2885cecad65bb1fb746f90d3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2014-11-28  Andrei Borzenkov  <arvidjaar@gmail.com>
 
+       * util/grub-install-common.c (grub_install_get_target): Check return
+       value of grub_util_fd_read (Coverity CID 73819).
        * util/grub-mkstandalone.c (add_tar_file): Fix out of bound access
        to hd.magic (Coverity CID 73587, 73888, bug 43690).
 
index c8bedcb2e593e14c703206bb46ce3168fb43d073..4b5d4d48668974971c00e3eadd4d9a7276854e2a 100644 (file)
@@ -911,6 +911,8 @@ grub_install_get_target (const char *src)
     grub_util_error (_("%s doesn't exist. Please specify --target or --directory"), 
                     fn);
   r = grub_util_fd_read (f, buf, sizeof (buf) - 1);
+  if (r < 0)
+    grub_util_error (_("cannot read `%s': %s"), fn, strerror (errno));
   grub_util_fd_close (f);
   buf[r] = '\0';
   c = strstr (buf, "grub_modinfo_target_cpu=");