sysfs_unique_holder(): Check read() return value before using as buffer index

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2011-11-01 16:09:20 +01:00 committed by NeilBrown
parent fb745c4bb4
commit 93f1df3355
1 changed files with 2 additions and 0 deletions

View File

@ -796,6 +796,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') {