md5: Return a NULL pointer if MD5::raw_digest() is called early

This never happens since MD5::raw_digest()'s only caller, util::md5(),
always does it right. However, it's still an open invitation for someone
to read garbage past the end of a 1 byte array, or even worse, write
into it. I'd rather have us crash by dereferencing the null page in that
case instead.
This commit is contained in:
Ignacio R. Morelle 2015-06-02 19:33:49 -03:00
parent 7be7e3ce8c
commit fbe7a58c6f

View file

@ -163,7 +163,7 @@ MD5::uint1 *MD5::raw_digest()
if (!finalized){
std::cerr << "MD5::raw_digest: Can't get digest if you haven't "<<
"finalized the digest!" <<std::endl;
return ( const_cast<uint1*>(reinterpret_cast<const uint1*>("")));
return NULL;
}
memcpy(s, digest, 16);