Check if open() was successful 03/212103/6
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 13 Aug 2019 11:25:39 +0000 (13:25 +0200)
committerMichal Bloch <m.bloch@partner.samsung.com>
Wed, 11 Sep 2019 10:59:27 +0000 (10:59 +0000)
Change-Id: I801699a864f2df60bfae0734fce20a925c104553

src/livedumper/livedumper.hpp

index 01a2225..4b83703 100644 (file)
@@ -223,6 +223,8 @@ class LiveDumper {
                        m_core.SaveNotes(m_core_file);
                        std::string mem_path = std::string("/proc/" + std::to_string(m_pid) + "/mem");
                        int mem_fd = open(mem_path.c_str(), O_RDONLY);
+                       if (mem_fd == -1)
+                               throw std::system_error(errno, std::system_category(), "open() for " + mem_path + " failed");
                        m_core.SaveLoadable(mem_fd, m_core_file, minicore);
                        if (minicore) {
                                m_core.SaveAUXVData(GetExePath(m_pid), mem_fd, m_core_file);