From ff76846e8b3474c1230b4a5ee8f85c444e2245b3 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 3 Dec 2018 00:28:24 +0100 Subject: [PATCH] Don't use pubsetbuf() when using libc++ Otherwise the eof bit is set on attempt to read --- CMakeLists.txt | 2 +- io/passwordfile.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93884bf..367c8c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index 90ee01f..f127646 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -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(remainingSize)); +#else decryptedStream.rdbuf()->pubsetbuf(decryptedData.data(), static_cast(remainingSize)); +#endif if (version >= 0x5u) { const auto extendedHeaderSize = m_freader.readUInt16BE(); m_encryptedExtendedHeader = m_freader.readString(extendedHeaderSize);