From 6498ccddb2f13a6fac6a210372b1aa86873507b9 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Wed, 1 Oct 2014 08:05:54 -0400 Subject: misc: Fix issues identified by static analysis Another bunch of issues addressed. --- src/base/loader/object_file.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/base/loader') diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc index 170e18d5e..29cea8ccf 100644 --- a/src/base/loader/object_file.cc +++ b/src/base/loader/object_file.cc @@ -54,7 +54,8 @@ ObjectFile::ObjectFile(const string &_filename, int _fd, size_t _len, uint8_t *_data, Arch _arch, OpSys _opSys) : filename(_filename), descriptor(_fd), fileData(_data), len(_len), - arch(_arch), opSys(_opSys), globalPtr(0) + arch(_arch), opSys(_opSys), entry(0), globalPtr(0), + text{0, nullptr, 0}, data{0, nullptr, 0}, bss{0, nullptr, 0} { } @@ -116,7 +117,9 @@ createObjectFile(const string &fname, bool raw) } // find the length of the file by seeking to the end - size_t len = (size_t)lseek(fd, 0, SEEK_END); + off_t off = lseek(fd, 0, SEEK_END); + fatal_if(off < 0, "Failed to determine size of object file %s\n", fname); + size_t len = static_cast(off); // mmap the whole shebang uint8_t *fileData = -- cgit v1.2.3