From fe763516ae63cd09015514bb0469a30110ed5dec Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 21 Feb 2012 06:29:54 +0000 Subject: Be more rigorous about parsing invalid hashes. Report them only through validity checking. If detected normally, do a best-effort attempt so that things like CRC(1) SHA1(1) can be used to force reporting of proper checksums. --- src/lib/util/hashing.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib/util/hashing.c') diff --git a/src/lib/util/hashing.c b/src/lib/util/hashing.c index a1e3112adc6..618750b1946 100644 --- a/src/lib/util/hashing.c +++ b/src/lib/util/hashing.c @@ -85,6 +85,7 @@ inline int char_to_hex(char c) bool sha1_t::from_string(const char *string, int length) { // must be at least long enough to hold everything + memset(m_raw, 0, sizeof(m_raw)); if (length == -1) length = strlen(string); if (length < 2 * sizeof(m_raw)) @@ -127,6 +128,7 @@ const char *sha1_t::as_string(astring &buffer) const bool md5_t::from_string(const char *string, int length) { // must be at least long enough to hold everything + memset(m_raw, 0, sizeof(m_raw)); if (length == -1) length = strlen(string); if (length < 2 * sizeof(m_raw)) @@ -170,6 +172,7 @@ const char *md5_t::as_string(astring &buffer) const bool crc32_t::from_string(const char *string, int length) { // must be at least long enough to hold everything + m_raw = 0; if (length == -1) length = strlen(string); if (length < 2 * sizeof(m_raw)) @@ -221,6 +224,7 @@ void crc32_creator::append(const void *data, UINT32 length) bool crc16_t::from_string(const char *string, int length) { // must be at least long enough to hold everything + m_raw = 0; if (length == -1) length = strlen(string); if (length < 2 * sizeof(m_raw)) -- cgit v1.2.3-70-g09d2