Cleared UBsan error using non-null pointer

pull/35/head
Jeffrey Walton 2015-07-17 21:36:13 -04:00
parent 5f299d76a0
commit 434c56fcd2
1 changed files with 13 additions and 3 deletions

View File

@ -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
{