Thread (15 messages) 15 messages, 2 authors, 2011-11-03
STALE5345d

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

From: <hidden>
Date: 2011-11-02 14:42:09
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

Signed-off-by: Jes Sorensen <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help