Don't use pubsetbuf() when using libc++

Otherwise the eof bit is set on attempt to read
This commit is contained in:
Martchus 2018-12-03 00:28:24 +01:00
parent 60d8972dcb
commit ff76846e8b
2 changed files with 5 additions and 1 deletions

View File

@ -44,7 +44,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files")
set(META_VERSION_MAJOR 3)
set(META_VERSION_MINOR 2)
set(META_VERSION_PATCH 0)
set(META_VERSION_PATCH 1)
set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities)
set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)

View File

@ -291,7 +291,11 @@ void PasswordFile::load()
stringstream decryptedStream(stringstream::in | stringstream::out | stringstream::binary);
decryptedStream.exceptions(ios_base::failbit | ios_base::badbit);
try {
#ifdef _LIBCPP_VERSION
decryptedStream.write(decryptedData.data(), static_cast<streamsize>(remainingSize));
#else
decryptedStream.rdbuf()->pubsetbuf(decryptedData.data(), static_cast<streamsize>(remainingSize));
#endif
if (version >= 0x5u) {
const auto extendedHeaderSize = m_freader.readUInt16BE();
m_encryptedExtendedHeader = m_freader.readString(extendedHeaderSize);