Bug 1153090 - Unaligned access in cert bock list. r=keeler, a=sledru
☠☠ backed out by adf4eb3666dd ☠ ☠
authorMark Goodwin <mgoodwin@mozilla.com>
Tue, 14 Apr 2015 02:55:00 -0400
changeset 263214 51ef02cbd50bc1cdf3eef33904e78e5f57a24c2e
parent 263213 1687db474cd21946901fa9f1297de4da58cf088e
child 263215 098c9a1c1390a9863bc17e5668b042dc7deb8d8d
push id1963
push userpaolo.mozmail@amadzone.org
push dateSun, 10 May 2015 10:26:20 +0000
reviewerskeeler, sledru
bugs1153090
milestone39.0a2
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")