Thread (24 messages) 24 messages, 3 authors, 2011-11-02
STALE5349d

[PATCH 04/19] sysfs_unique_holder(): Check read() return value before using as buffer index

From: <hidden>
Date: 2011-11-01 15:09:20
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

Signed-off-by: Jes Sorensen <redacted>
---
 sysfs.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/sysfs.c b/sysfs.c
index 05f0118..10e1597 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -804,6 +804,8 @@ int sysfs_unique_holder(int devnum, long rdev)
 		}
 		n = read(fd, buf, sizeof(buf)-1);
 		close(fd);
+		if (n < 0)
+			continue;
 		buf[n] = 0;
 		if (sscanf(buf, "%d:%d%c", &mj, &mn, &c) != 3 ||
 		    c != '\n') {
-- 
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