[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH] fw_cfg: check return value of fread()
From: |
Pavel Borzenkov |
Subject: |
[Qemu-trivial] [PATCH] fw_cfg: check return value of fread() |
Date: |
Tue, 18 Oct 2011 21:16:48 +0400 |
Spotted by Clang Analyzer
Signed-off-by: Pavel Borzenkov <address@hidden>
---
hw/fw_cfg.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 8df265c..1125e7d 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -113,6 +113,13 @@ static FILE *probe_splashfile(char *filename, int
*file_sizep, int *file_typep)
if (file_type == BMP_FILE) {
fseek(fp, 28, SEEK_SET);
fop_ret = fread(buf, 1, 2, fp);
+ if (fop_ret != 2) {
+ error_report("Could not read bpp value from '%s': %s",
+ filename, strerror(errno));
+ fclose(fp);
+ fp = NULL;
+ return fp;
+ }
bmp_bpp = (buf[0] + (buf[1] << 8)) & 0xffff;
if (bmp_bpp != 24) {
error_report("only 24bpp bmp file is supported.");
--
1.7.7
- [Qemu-trivial] [PATCH] fw_cfg: check return value of fread(),
Pavel Borzenkov <=