b=477727; fix unaligned access in URL classifier; r=dcamp,sr=stuart
--- a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp
@@ -2164,18 +2164,19 @@ nsUrlClassifierDBServiceWorker::GetShaEn
if (chunkType == CHUNK_SUB) {
if (start + 4 > chunk.Length()) {
// there isn't as much data as there should be.
NS_WARNING("Received a zero-entry sub chunk without an associated add.");
return NS_ERROR_FAILURE;
}
const nsCSubstring& str = Substring(chunk, start, 4);
- const PRUint32 *p = reinterpret_cast<const PRUint32*>(str.BeginReading());
- entry->mAddChunkId = PR_ntohl(*p);
+ PRUint32 p;
+ memcpy(&p, str.BeginReading(), 4);
+ entry->mAddChunkId = PR_ntohl(p);
if (entry->mAddChunkId == 0) {
NS_WARNING("Received invalid chunk number.");
return NS_ERROR_FAILURE;
}
start += 4;
}
} else {
PRUint32 entrySize = fragmentSize;
@@ -2193,18 +2194,19 @@ nsUrlClassifierDBServiceWorker::GetShaEn
if (!entry) return NS_ERROR_OUT_OF_MEMORY;
entry->mKey = domain;
entry->mTableId = tableId;
entry->mChunkId = chunkNum;
if (chunkType == CHUNK_SUB) {
const nsCSubstring& str = Substring(chunk, start, 4);
- const PRUint32 *p = reinterpret_cast<const PRUint32*>(str.BeginReading());
- entry->mAddChunkId = PR_ntohl(*p);
+ PRUint32 p;
+ memcpy(&p, str.BeginReading(), 4);
+ entry->mAddChunkId = PR_ntohl(p);
if (entry->mAddChunkId == 0) {
NS_WARNING("Received invalid chunk number.");
return NS_ERROR_FAILURE;
}
start += 4;
}
if (fragmentSize == PARTIAL_LENGTH) {