[Skiboot] [PATCH] hdata test: Check the return value from lseek
Kamalesh Babulal
kamalesh at linux.vnet.ibm.com
Fri Jul 3 20:24:04 AEST 2015
Check if value returned by lseek is non-negative, as we
will be passing it mmap. Fix it up, by aborting on negative
value.
Fixes Coverity defect#98808.
Signed-off-by: Kamalesh Babulal <kamalesh at linux.vnet.ibm.com>
---
hdata/test/hdata_to_dt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index 64749eb..87cc92d 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -195,6 +195,8 @@ int main(int argc, char *argv[])
if (fd < 0)
err(1, "opening %s", argv[2]);
spira_heap_size = lseek(fd, 0, SEEK_END);
+ if (spira_heap_size < 0)
+ err(1, "lseek on %s", argv[2]);
spira_heap = mmap(NULL, spira_heap_size, PROT_READ, MAP_SHARED, fd, 0);
if (spira_heap == MAP_FAILED)
err(1, "mmaping %s", argv[3]);
--
2.1.2
More information about the Skiboot
mailing list