mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix some clang warnings
This commit is contained in:
parent
b98f8c4fe7
commit
7da9187808
|
@ -307,7 +307,8 @@ template<typename T>
|
|||
std::vector<T> read_vector(std::istream &in, std::size_t count)
|
||||
{
|
||||
std::vector<T> result(count, T());
|
||||
in.read(reinterpret_cast<char *>(&result[0]), sizeof(T) * count);
|
||||
in.read(reinterpret_cast<char *>(&result[0]),
|
||||
static_cast<std::streamsize>(sizeof(T) * count));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -316,7 +317,8 @@ template<typename T>
|
|||
std::basic_string<T> read_string(std::istream &in, std::size_t count)
|
||||
{
|
||||
std::basic_string<T> result(count, T());
|
||||
in.read(reinterpret_cast<char *>(&result[0]), sizeof(T) * count);
|
||||
in.read(reinterpret_cast<char *>(&result[0]),
|
||||
static_cast<std::streamsize>(sizeof(T) * count));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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<std::ctype<char>>(locale).tolower(&s[0], &s[0] + s.size());
|
||||
static const auto *locale = new std::locale();
|
||||
std::use_facet<std::ctype<char>>(*locale).tolower(&s[0], &s[0] + s.size());
|
||||
return s;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ std::vector<std::uint8_t> decrypt_xlsx_standard(
|
|||
{
|
||||
encrypted_package_stream.read(
|
||||
reinterpret_cast<char *>(encrypted_segment.data()),
|
||||
encrypted_segment.size());
|
||||
static_cast<std::streamsize>(encrypted_segment.size()));
|
||||
auto decrypted_segment = xlnt::detail::aes_ecb_decrypt(encrypted_segment, key);
|
||||
|
||||
decrypted_package.insert(
|
||||
|
@ -97,7 +97,7 @@ std::vector<std::uint8_t> decrypt_xlsx_agile(
|
|||
|
||||
encrypted_package_stream.read(
|
||||
reinterpret_cast<char *>(encrypted_segment.data()),
|
||||
encrypted_segment.size());
|
||||
static_cast<std::streamsize>(encrypted_segment.size()));
|
||||
auto decrypted_segment = xlnt::detail::aes_cbc_decrypt(encrypted_segment, key, iv);
|
||||
|
||||
decrypted_package.insert(
|
||||
|
|
|
@ -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<char *>(result.data()), result.size());
|
||||
info_stream.write(reinterpret_cast<char *>(result.data()),
|
||||
static_cast<std::streamsize>(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<std::ptrdiff_t>(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<std::ptrdiff_t>(bytes), segment.begin());
|
||||
auto encrypted_segment = xlnt::detail::aes_cbc_encrypt(segment, key, iv);
|
||||
ciphertext_stream.write(reinterpret_cast<char *>(encrypted_segment.data()), bytes);
|
||||
ciphertext_stream.write(reinterpret_cast<char *>(encrypted_segment.data()),
|
||||
static_cast<std::streamsize>(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<std::ptrdiff_t>(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<std::ptrdiff_t>(bytes), segment.begin());
|
||||
auto encrypted_segment = xlnt::detail::aes_ecb_encrypt(segment, key);
|
||||
ciphertext_stream.write(reinterpret_cast<char *>(encrypted_segment.data()), bytes);
|
||||
ciphertext_stream.write(reinterpret_cast<char *>(encrypted_segment.data()),
|
||||
static_cast<std::streamsize>(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user