[PATCH 04/12] get_component_size(): Check read() return value for error before using it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
---
 sysfs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sysfs.c b/sysfs.c
index 10e1597..d501792 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -387,7 +387,7 @@ unsigned long long get_component_size(int fd)
 		return 0;
 	n = read(fd, fname, sizeof(fname));
 	close(fd);
-	if (n == sizeof(fname))
+	if (n < 0 || n == sizeof(fname))
 		return 0;
 	fname[n] = 0;
 	return strtoull(fname, NULL, 10) * 2;
-- 
1.7.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux