diff --git a/src/basicio.cpp b/src/basicio.cpp index cf5d0381..2bf7cf7e 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -297,7 +297,9 @@ namespace Exiv2 { } p_->mappedLength_ = size(); p_->isWriteable_ = isWriteable; - if (p_->isWriteable_ && p_->switchMode(Impl::opWrite) != 0) return 0; + if (p_->isWriteable_ && p_->switchMode(Impl::opWrite) != 0) { + throw Error(16, path(), strError()); + } #if defined EXV_HAVE_MMAP && defined EXV_HAVE_MUNMAP int prot = PROT_READ; if (p_->isWriteable_) { @@ -343,7 +345,9 @@ namespace Exiv2 { #else // Workaround for platforms without mmap: Read the file into memory DataBuf buf(static_cast(p_->mappedLength_)); - read(buf.pData_, buf.size_); + if (read(buf.pData_, buf.size_) != buf.size_) { + throw Error(2, path(), strError(), "FileIo::read"); + } if (error() || eof()) throw Error(2, path(), strError(), "FileIo::mmap"); p_->pMappedArea_ = buf.release().first; p_->isMalloced_ = true; diff --git a/src/error.cpp b/src/error.cpp index 02983135..b7ca49e3 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -67,7 +67,7 @@ namespace { { 13, N_("Image type %1 is not supported") }, // %1=image type { 14, N_("Failed to read image data") }, { 15, N_("This does not look like a JPEG image") }, -// { 16, N_("") }, -- currently not used + { 16, N_("%1: Failed to map file for reading and writing: %2") }, // %1=path, %2=strerror { 17, N_("%1: Failed to rename file to %2: %3") }, // %1=old path, %2=new path, %3=strerror { 18, N_("%1: Transfer failed: %2") }, // %1=path, %2=strerror { 19, N_("Memory transfer failed: %1") }, // %1=strerror