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:
parent
fb745c4bb4
commit
93f1df3355
2
sysfs.c
2
sysfs.c
|
@ -796,6 +796,8 @@ int sysfs_unique_holder(int devnum, long rdev)
|
||||||
}
|
}
|
||||||
n = read(fd, buf, sizeof(buf)-1);
|
n = read(fd, buf, sizeof(buf)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
if (n < 0)
|
||||||
|
continue;
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
if (sscanf(buf, "%d:%d%c", &mj, &mn, &c) != 3 ||
|
if (sscanf(buf, "%d:%d%c", &mj, &mn, &c) != 3 ||
|
||||||
c != '\n') {
|
c != '\n') {
|
||||||
|
|
Loading…
Reference in New Issue