diff options
author | Jeffrey Walton <noloader@gmail.com> | 2015-07-19 07:58:55 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2015-07-19 07:58:55 -0400 |
commit | d19790bbcacd8ea7295d4429a11ff5631a924144 (patch) | |
tree | 013e6428ea1343309cd0fecba9264a07c493fc55 /modes.cpp | |
parent | b54e637896decdcd2e7b4878326e695639ca50d7 (diff) | |
download | cryptopp-git-d19790bbcacd8ea7295d4429a11ff5631a924144.tar.gz |
Cleared UBsan errors
Diffstat (limited to 'modes.cpp')
-rw-r--r-- | modes.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -29,7 +29,7 @@ void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, siz assert(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt assert(m_feedbackSize == BlockSize()); - unsigned int s = BlockSize(); + const unsigned int s = BlockSize(); if (dir == ENCRYPTION) { m_cipher->ProcessAndXorBlock(m_register, input, output); @@ -38,10 +38,10 @@ void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, siz } else { - memcpy(m_temp, input+(iterationCount-1)*s, s); // make copy first in case of in-place decryption + memcpy_s(m_temp, m_temp.size(), input+(iterationCount-1)*s, s); // make copy first in case of in-place decryption m_cipher->AdvancedProcessBlocks(input, input+s, output+s, (iterationCount-1)*s, BlockTransformation::BT_ReverseDirection); m_cipher->ProcessAndXorBlock(m_register, input, output); - memcpy(m_register, m_temp, s); + memcpy_s(m_register, m_register.size(), m_temp, s); } } @@ -49,8 +49,10 @@ void CFB_ModePolicy::TransformRegister() { assert(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt m_cipher->ProcessBlock(m_register, m_temp); - unsigned int updateSize = BlockSize()-m_feedbackSize; - memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize); + const unsigned int updateSize = BlockSize()-m_feedbackSize; + + if(updateSize) + memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize); memcpy_s(m_register+updateSize, m_register.size()-updateSize, m_temp, m_feedbackSize); } |