get_component_size(): Check read() return value for error before using it

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-03 08:07:39 +11:00 committed by NeilBrown
parent d94a4f62bf
commit 99f6e52159
1 changed files with 1 additions and 1 deletions

View File

@ -379,7 +379,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;