summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/hashing.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2012-02-21 06:29:54 +0000
committer Aaron Giles <aaron@aarongiles.com>2012-02-21 06:29:54 +0000
commitfe763516ae63cd09015514bb0469a30110ed5dec (patch)
treed7a615643cd1877b41eee7d739ab8a108d923ad0 /src/lib/util/hashing.c
parent1824c80bdde513479188c2f0cc0ba1219e874000 (diff)
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.
Diffstat (limited to 'src/lib/util/hashing.c')
-rw-r--r--src/lib/util/hashing.c4
1 files changed, 4 insertions, 0 deletions
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))