ivshmem: check the value returned by fstat()

The function fstat() may fail, so check its return value.

Acked-by: Levente Kurusa <lkurusa@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
zhanghailiang 2014-08-14 15:29:15 +08:00 committed by Michael Tokarev
parent 2c145d7a73
commit 5edbdbcdf8

View file

@ -324,7 +324,11 @@ static int check_shm_size(IVShmemState *s, int fd) {
struct stat buf;
fstat(fd, &buf);
if (fstat(fd, &buf) < 0) {
fprintf(stderr, "ivshmem: exiting: fstat on fd %d failed: %s\n",
fd, strerror(errno));
return -1;
}
if (s->ivshmem_size > buf.st_size) {
fprintf(stderr,