size = st.st_size;
of_path = xmalloc (size + MAX_DISK_CAT + 1);
memset(of_path, 0, size + MAX_DISK_CAT + 1);
- read(fd, of_path, size);
+ if (read(fd, of_path, size) < 0)
+ {
+ grub_util_info (_("cannot read `%s': %s"), path, strerror (errno));
+ close(fd);
+ return NULL;
+ }
close(fd);
trim_newline(of_path);
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy));
- read (fd, phy, sizeof (phy) - 1);
+ if (read (fd, phy, sizeof (phy) - 1) < 0)
+ grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
+
close (fd);
sscanf (phy, "%d", tgt);
snprintf (path, path_size, "%s/sas_device/%s/sas_address", p, ed);
fd = open (path, O_RDONLY);
if (fd < 0)
- grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
memset (phy, 0, sizeof (phy));
- read (fd, phy, sizeof (phy) - 1);
+ if (read (fd, phy, sizeof (phy) - 1) < 0)
+ grub_util_error (_("cannot read `%s': %s"), path, strerror (errno));
sscanf (phy, "%lx", sas_address);
free (path);