diff options
Diffstat (limited to 'libs/utils/BackupData.cpp')
-rw-r--r-- | libs/utils/BackupData.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp index be04777..0cef35a 100644 --- a/libs/utils/BackupData.cpp +++ b/libs/utils/BackupData.cpp @@ -193,9 +193,11 @@ BackupDataReader::Status() if ((actual) != (expected)) { \ if ((actual) == 0) { \ m_status = EIO; \ + m_done = true; \ } else { \ m_status = errno; \ } \ + LOGD("CHECK_SIZE failed with at line %d m_status='%s'", __LINE__, strerror(m_status)); \ return m_status; \ } \ } while(0) @@ -203,6 +205,7 @@ BackupDataReader::Status() do { \ status_t err = skip_padding(); \ if (err != NO_ERROR) { \ + LOGD("SKIP_PADDING FAILED at line %d", __LINE__); \ m_status = err; \ return err; \ } \ @@ -218,10 +221,19 @@ BackupDataReader::ReadNextHeader(bool* done, int* type) int amt; - // No error checking here, in case we're at the end of the stream. Just let read() fail. - skip_padding(); + amt = skip_padding(); + if (amt == EIO) { + *done = m_done = true; + return NO_ERROR; + } + else if (amt != NO_ERROR) { + return amt; + } amt = read(m_fd, &m_header, sizeof(m_header)); *done = m_done = (amt == 0); + if (*done) { + return NO_ERROR; + } CHECK_SIZE(amt, sizeof(m_header)); m_pos += sizeof(m_header); if (type) { @@ -327,6 +339,10 @@ BackupDataReader::ReadEntityData(void* data, size_t size) m_status = errno; return -1; } + if (amt == 0) { + m_status = EIO; + m_done = true; + } m_pos += amt; return amt; } |