diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2019-09-18 11:34:49 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2019-09-18 11:39:06 +0200 |
commit | 4c57a50fe77665ec6408e3464abc725cf417076f (patch) | |
tree | 3f3fa2cbe2be47c8747e32666cf0d7ff3cd34d2c | |
parent | 47b75b24ed89ba6e0b69aef1fe49e50913f24cc7 (diff) | |
download | crash-worker-4c57a50fe77665ec6408e3464abc725cf417076f.tar.gz crash-worker-4c57a50fe77665ec6408e3464abc725cf417076f.tar.bz2 crash-worker-4c57a50fe77665ec6408e3464abc725cf417076f.zip |
Fix Coverity issues
Change-Id: I84d25d996c2134e141bb366ca3adc77743ba98ba
-rw-r--r-- | src/livedumper/core.hpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/livedumper/core.hpp b/src/livedumper/core.hpp index aebd3a4..bd1737c 100644 --- a/src/livedumper/core.hpp +++ b/src/livedumper/core.hpp @@ -222,13 +222,18 @@ class Core { } void ReadFromFile(const int fd, unsigned long address, void *data, size_t len) { - lseek64(fd, address, SEEK_SET); + if (lseek64(fd, address, SEEK_SET) == -1) + throw std::system_error(errno, std::system_category(), "failed to lseek64 at " + std::to_string(address)); if (read(fd, data, len) == -1) throw std::system_error(errno, std::system_category(), "failed to read at " + std::to_string(address)); } void DumpData(int fd, std::ofstream &output, typename T::Addr iaddress, typename T::Addr oaddress, size_t len, const std::string &desc) { - lseek64(fd, iaddress, SEEK_SET); + if (lseek64(fd, iaddress, SEEK_SET) == -1) { + logger.log_info("failed to lseek64"); + return; + } + output.seekp(oaddress, std::ios_base::beg); constexpr const char * format = std::is_same<T, Elf64>::value ? "dumping %s: 0x%" PRIx64 "-0x%" PRIx64 " to 0x%" PRIx64 " (%zu bytes)" : @@ -459,7 +464,7 @@ class Core { ReadFromFile(mem_fd, addr, buff, sizeof(buff)); if (buff[0] != 0) { - DumpData(mem_fd, core_file, addr, strlen(buff) + 1, "l_name"); + DumpData(mem_fd, core_file, addr, strnlen(buff, sizeof(buff)) + 1, "l_name"); ReadFromFile(mem_fd, ptr+offsetof(struct link_map, l_addr), &addr, sizeof(addr)); SaveSymData(buff, addr); } |