diff --git a/source/detail/binary.hpp b/source/detail/binary.hpp index a4180f20..e9088701 100644 --- a/source/detail/binary.hpp +++ b/source/detail/binary.hpp @@ -307,7 +307,8 @@ template std::vector read_vector(std::istream &in, std::size_t count) { std::vector result(count, T()); - in.read(reinterpret_cast(&result[0]), sizeof(T) * count); + in.read(reinterpret_cast(&result[0]), + static_cast(sizeof(T) * count)); return result; } @@ -316,7 +317,8 @@ template std::basic_string read_string(std::istream &in, std::size_t count) { std::basic_string result(count, T()); - in.read(reinterpret_cast(&result[0]), sizeof(T) * count); + in.read(reinterpret_cast(&result[0]), + static_cast(sizeof(T) * count)); return result; } diff --git a/source/detail/cryptography/compound_document.cpp b/source/detail/cryptography/compound_document.cpp index d3f47814..42e10aae 100644 --- a/source/detail/cryptography/compound_document.cpp +++ b/source/detail/cryptography/compound_document.cpp @@ -43,8 +43,8 @@ int compare_keys(const std::string &left, const std::string &right) { auto to_lower = [](std::string s) { - static const auto locale = std::locale(); - std::use_facet>(locale).tolower(&s[0], &s[0] + s.size()); + static const auto *locale = new std::locale(); + std::use_facet>(*locale).tolower(&s[0], &s[0] + s.size()); return s; }; diff --git a/source/detail/cryptography/xlsx_crypto_consumer.cpp b/source/detail/cryptography/xlsx_crypto_consumer.cpp index fdc53a96..be96920b 100644 --- a/source/detail/cryptography/xlsx_crypto_consumer.cpp +++ b/source/detail/cryptography/xlsx_crypto_consumer.cpp @@ -60,7 +60,7 @@ std::vector decrypt_xlsx_standard( { encrypted_package_stream.read( reinterpret_cast(encrypted_segment.data()), - encrypted_segment.size()); + static_cast(encrypted_segment.size())); auto decrypted_segment = xlnt::detail::aes_ecb_decrypt(encrypted_segment, key); decrypted_package.insert( @@ -97,7 +97,7 @@ std::vector decrypt_xlsx_agile( encrypted_package_stream.read( reinterpret_cast(encrypted_segment.data()), - encrypted_segment.size()); + static_cast(encrypted_segment.size())); auto decrypted_segment = xlnt::detail::aes_cbc_decrypt(encrypted_segment, key, iv); decrypted_package.insert( diff --git a/source/detail/cryptography/xlsx_crypto_producer.cpp b/source/detail/cryptography/xlsx_crypto_producer.cpp index 6d1973a0..07448d8b 100644 --- a/source/detail/cryptography/xlsx_crypto_producer.cpp +++ b/source/detail/cryptography/xlsx_crypto_producer.cpp @@ -210,7 +210,8 @@ void write_standard_encryption_info(const encryption_info &info, std::ostream &i writer.write(std::uint32_t(20)); writer.append(info.standard.encrypted_verifier_hash); - info_stream.write(reinterpret_cast(result.data()), result.size()); + info_stream.write(reinterpret_cast(result.data()), + static_cast(result.size())); } void encrypt_xlsx_agile( @@ -235,11 +236,12 @@ void encrypt_xlsx_agile( auto iv = hash(info.agile.key_encryptor.hash, salt_with_block_key); iv.resize(16); - auto start = plaintext.begin() + i; + auto start = plaintext.begin() + static_cast(i); auto bytes = std::min(std::size_t(length - i), std::size_t(4096)); - std::copy(start, start + bytes, segment.begin()); + std::copy(start, start + static_cast(bytes), segment.begin()); auto encrypted_segment = xlnt::detail::aes_cbc_encrypt(segment, key, iv); - ciphertext_stream.write(reinterpret_cast(encrypted_segment.data()), bytes); + ciphertext_stream.write(reinterpret_cast(encrypted_segment.data()), + static_cast(bytes)); ++segment_index; } @@ -258,11 +260,12 @@ void encrypt_xlsx_standard( for (auto i = std::size_t(0); i < length; ++i) { - auto start = plaintext.begin() + i; + auto start = plaintext.begin() + static_cast(i); auto bytes = std::min(std::size_t(length - i), std::size_t(4096)); - std::copy(start, start + bytes, segment.begin()); + std::copy(start, start + static_cast(bytes), segment.begin()); auto encrypted_segment = xlnt::detail::aes_ecb_encrypt(segment, key); - ciphertext_stream.write(reinterpret_cast(encrypted_segment.data()), bytes); + ciphertext_stream.write(reinterpret_cast(encrypted_segment.data()), + static_cast(bytes)); } }