Bug 1153090 - Unaligned access in cert bock list. r=keeler, a=sledru
authorMark Goodwin <mgoodwin@mozilla.com>
Tue, 14 Apr 2015 02:55:00 -0400
changeset 258490 58f203b17be2
parent 258489 df47a99c442f
child 258491 e10ddd2bc05f
push id4679
push userryanvm@gmail.com
push date2015-04-15 17:06 +0000
treeherdermozilla-beta@6c7e8d9f955c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler, sledru
bugs1153090
milestone38.0
Bug 1153090 - Unaligned access in cert bock list. r=keeler, a=sledru
security/manager/boot/src/CertBlocklist.cpp
--- 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")