mirror of https://github.com/xqemu/xqemu.git
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:
parent
2c145d7a73
commit
5edbdbcdf8
|
@ -324,7 +324,11 @@ static int check_shm_size(IVShmemState *s, int fd) {
|
||||||
|
|
||||||
struct stat buf;
|
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) {
|
if (s->ivshmem_size > buf.st_size) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
Loading…
Reference in New Issue