From c99943c2718ffd6d9915d660cc0363feb4aa386b Mon Sep 17 00:00:00 2001 From: "mark%moxienet.com" Date: Sat, 4 Feb 2006 22:01:22 +0000 Subject: [PATCH] 325765 Cache causes crash crossing architecture [@ nsDiskCacheRecord::HashNumber].[@ nsDiskCacheMap::FindRecord]. Disk cache is not endian-neutral as was intended. Byte-swap the entire cache header. r=darin sr=smfr a/1.8=darin git-svn-id: svn://10.0.0.236/trunk@188939 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/cache/src/nsDiskCache.h | 2 +- mozilla/netwerk/cache/src/nsDiskCacheMap.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mozilla/netwerk/cache/src/nsDiskCache.h b/mozilla/netwerk/cache/src/nsDiskCache.h index ec350f7d164..4151924d8e2 100644 --- a/mozilla/netwerk/cache/src/nsDiskCache.h +++ b/mozilla/netwerk/cache/src/nsDiskCache.h @@ -53,7 +53,7 @@ class nsDiskCache { public: enum { - kCurrentVersion = 0x00010007 // format = 16 bits major version/16 bits minor version + kCurrentVersion = 0x00010009 // format = 16 bits major version/16 bits minor version }; enum { kData, kMetaData }; diff --git a/mozilla/netwerk/cache/src/nsDiskCacheMap.h b/mozilla/netwerk/cache/src/nsDiskCacheMap.h index 8e3fca84869..d83b9adff7f 100644 --- a/mozilla/netwerk/cache/src/nsDiskCacheMap.h +++ b/mozilla/netwerk/cache/src/nsDiskCacheMap.h @@ -358,6 +358,11 @@ struct nsDiskCacheHeader { mEntryCount = htonl(mEntryCount); mIsDirty = htonl(mIsDirty); mRecordCount = htonl(mRecordCount); + + for (PRUint32 i = 0; i < kBuckets ; i++) { + mEvictionRank[i] = htonl(mEvictionRank[i]); + mBucketUsage[i] = htonl(mBucketUsage[i]); + } #endif } @@ -369,6 +374,11 @@ struct nsDiskCacheHeader { mEntryCount = ntohl(mEntryCount); mIsDirty = ntohl(mIsDirty); mRecordCount = ntohl(mRecordCount); + + for (PRUint32 i = 0; i < kBuckets ; i++) { + mEvictionRank[i] = ntohl(mEvictionRank[i]); + mBucketUsage[i] = ntohl(mBucketUsage[i]); + } #endif } };