summaryrefslogtreecommitdiff
path: root/pssr.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-07-17 21:36:13 -0400
committerJeffrey Walton <noloader@gmail.com>2015-07-17 21:36:13 -0400
commit434c56fcd27119d902aa71201283f9537697ed91 (patch)
treedd0f104ca589dfad51ab9c54100d956450c90a1c /pssr.cpp
parent5f299d76a0d8f5374b8018faa65465632c45d13e (diff)
downloadcryptopp-git-434c56fcd27119d902aa71201283f9537697ed91.tar.gz
Cleared UBsan error using non-null pointer
Diffstat (limited to 'pssr.cpp')
-rw-r--r--pssr.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/pssr.cpp b/pssr.cpp
index 2220a9b6..f76f994a 100644
--- a/pssr.cpp
+++ b/pssr.cpp
@@ -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
{