diff options
author | Jeffrey Walton <noloader@gmail.com> | 2015-07-17 21:36:13 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2015-07-17 21:36:13 -0400 |
commit | 434c56fcd27119d902aa71201283f9537697ed91 (patch) | |
tree | dd0f104ca589dfad51ab9c54100d956450c90a1c /pssr.cpp | |
parent | 5f299d76a0d8f5374b8018faa65465632c45d13e (diff) | |
download | cryptopp-git-434c56fcd27119d902aa71201283f9537697ed91.tar.gz |
Cleared UBsan error using non-null pointer
Diffstat (limited to 'pssr.cpp')
-rw-r--r-- | pssr.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -75,8 +75,17 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, xorStart[0] ^= 1; xorbuf(xorStart + 1, recoverableMessage, recoverableMessageLength); xorbuf(xorStart + 1 + recoverableMessageLength, salt, salt.size()); - memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second); - representative[representativeByteLength - 1] = hashIdentifier.second ? 0xcc : 0xbc; + + if(representative && hashIdentifier.first && hashIdentifier.second) + { + memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second); + representative[representativeByteLength - 1] = 0xcc; + } + else + { + representative[representativeByteLength - 1] = 0xbc; + } + if (representativeBitLength % 8 != 0) representative[0] = (byte)Crop(representative[0], representativeBitLength % 8); } @@ -116,7 +125,8 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( && (size_t)(M - representative - (representativeBitLength % 8 != 0)) >= MinPadLen(digestSize) && recoverableMessageLength <= MaxRecoverableLength(representativeBitLength, hashIdentifier.second, digestSize)) { - memcpy(recoverableMessage, M+1, recoverableMessageLength); + if(recoverableMessage && M && recoverableMessageLength) + memcpy(recoverableMessage, M+1, recoverableMessageLength); } else { |