Bug 1153090 - Unaligned access in cert bock list. r=keeler, a=sledru
--- a/security/manager/boot/src/CertBlocklist.cpp
+++ b/security/manager/boot/src/CertBlocklist.cpp
@@ -79,20 +79,21 @@ CertBlocklistItem::operator==(const Cert
return retval;
}
uint32_t
CertBlocklistItem::Hash() const
{
uint32_t hash;
uint32_t serialLength = mSerial.GetLength();
- // there's no requirement for a serial to be as large as 32 bits; if it's
- // smaller, fall back to the first octet (otherwise, the last four)
- if (serialLength >= 4) {
- hash = *(uint32_t *)(mSerialData + serialLength - 4);
+ // there's no requirement for a serial to be as large as the size of the hash
+ // key; if it's smaller, fall back to the first octet (otherwise, the last
+ // four)
+ if (serialLength >= sizeof(hash) {
+ memcpy(&hash, mSerialData + serialLength - sizeof(hash), sizeof(hash));
} else {
hash = *mSerialData;
}
return hash;
}
CertBlocklist::CertBlocklist()
: mMutex("CertBlocklist::mMutex")