m_proc(proc)
{
InitContext(key.c_str(), key.length(), &m_ctx);
+ memset(m_buffer, 0, sizeof(m_buffer));
}
void Put(const void * data, size_t size, bool last)
{
memcpy(m_ptr, data, sizeof(m_buffer) - dataSize); // Fill buffer
size -= sizeof(m_buffer) - dataSize; // Adjust size
- data += sizeof(m_buffer) - dataSize; // Adjust data pointer
+ data = static_cast<const char *>(data) + sizeof(m_buffer) - dataSize; // Adjust data pointer
m_proc(m_buffer, m_buffer, sizeof(m_buffer), &m_ctx); // Process
m_callback(m_buffer, sizeof(m_buffer), m_data); // Consume
m_ptr = m_buffer;
STG::ENCRYPT_STREAM estream("pr7Hhen", Callback, &tracker);
std::string source = "This is a test long string for checking stream encryption/decryption. \"abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ\"";
char buffer[source.length() + 9];
+ memset(buffer, 0, sizeof(buffer));
estream.Put(source.c_str(), source.length() + 1, true);
ensure("Encryption long string LastSize()", tracker.LastSize() >= source.length() + 1);