summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/hash.c26
-rw-r--r--src/emu/romload.c9
-rw-r--r--src/lib/util/hashing.c4
3 files changed, 23 insertions, 16 deletions
diff --git a/src/emu/hash.c b/src/emu/hash.c
index 9d03e5cf9ba..76053a4d939 100644
--- a/src/emu/hash.c
+++ b/src/emu/hash.c
@@ -307,7 +307,7 @@ bool hash_collection::from_internal_string(const char *string)
// loop until we hit it
bool errors = false;
- bool skip_digits = false;
+ int skip_digits = 0;
while (ptr < stringend)
{
char c = *ptr++;
@@ -316,10 +316,21 @@ bool hash_collection::from_internal_string(const char *string)
// non-hex alpha values specify a hash type
if (uc >= 'G' && uc <= 'Z')
{
+ if (skip_digits != 0)
+ errors = true;
+ skip_digits = 0;
if (uc == HASH_CRC)
- skip_digits = m_has_crc32 = m_crc32.from_string(ptr, stringend - ptr);
+ {
+ m_has_crc32 = true;
+ errors = !m_crc32.from_string(ptr, stringend - ptr);
+ skip_digits = 2 * sizeof(crc32_t);
+ }
else if (uc == HASH_SHA1)
- skip_digits = m_has_sha1 = m_sha1.from_string(ptr, stringend - ptr);
+ {
+ m_has_sha1 = true;
+ errors = !m_sha1.from_string(ptr, stringend - ptr);
+ skip_digits = 2 * sizeof(sha1_t);
+ }
else
errors = true;
}
@@ -327,11 +338,15 @@ bool hash_collection::from_internal_string(const char *string)
// hex values are ignored, though unexpected
else if ((uc >= '0' && uc <= '9') || (uc >= 'A' && uc <= 'F'))
{
- if (!skip_digits)
+ if (skip_digits != 0)
+ skip_digits--;
+ else
errors = true;
}
// anything else is a flag
+ else if (skip_digits != 0)
+ errors = true;
else
m_flags.cat(c);
}
@@ -386,9 +401,6 @@ void hash_collection::end()
{
assert(m_creator != NULL);
- // default to getting nothing
- m_has_crc32 = m_has_sha1 = false;
-
// finish up the CRC32
if (m_creator->m_doing_crc32)
{
diff --git a/src/emu/romload.c b/src/emu/romload.c
index 78164fcee0c..99acddceef0 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -414,15 +414,6 @@ static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const hash_
astring tempstr;
romdata->errorstring.catprintf(" EXPECTED: %s\n", hashes.macro_string(tempstr));
romdata->errorstring.catprintf(" FOUND: %s\n", acthashes.macro_string(tempstr));
-/*
- // warn about any ill-formed hashes
- for (hash_base *hash = hashes.first(); hash != NULL; hash = hash->next())
- if (hash->parse_error())
- {
- romdata->errorstring.catprintf("\tInvalid %s checksum treated as 0 (check leading zeros)\n", hash->name());
- romdata->warnings++;
- }
-*/
}
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))