Backed out changeset 4efb6cc4fd5d (bug 1225004) for build bustage CLOSED TREE

This commit is contained in:
Wes Kocher 2015-11-16 14:51:17 -08:00
parent ecda574c7e
commit d2a6b5e418
6 changed files with 14 additions and 92 deletions

View File

@ -27,8 +27,6 @@
#include "nsIChromeRegistry.h"
#include "nsISimpleEnumerator.h"
#include "nsISubstitutingProtocolHandler.h"
#include "zlib.h"
#include "nsZipArchive.h"
#endif
using namespace mozilla;
@ -471,30 +469,6 @@ nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile,
}
#ifdef MOZ_CRASHREPORTER
static inline nsresult
ComputeCRC32(nsIFile* aFile, uint32_t* aResult)
{
PRFileDesc* fd;
nsresult rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t crc = crc32(0, nullptr, 0);
unsigned char buf[512];
int32_t n;
while ((n = PR_Read(fd, buf, sizeof(buf))) > 0) {
crc = crc32(crc, buf, n);
}
PR_Close(fd);
if (n < 0) {
return NS_ERROR_FAILURE;
}
*aResult = crc;
return NS_OK;
}
static void
ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile,
const nsTArray<nsString>& aInterestingFilenames)
@ -514,14 +488,7 @@ ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile,
} else {
aAnnotation.AppendLiteral("???");
}
aAnnotation.AppendLiteral(" bytes, crc32 = ");
uint32_t crc;
nsresult rv = ComputeCRC32(aFile, &crc);
if (NS_SUCCEEDED(rv)) {
aAnnotation.AppendPrintf("0x%08x)\n", crc);
} else {
aAnnotation.AppendPrintf("error 0x%08x)\n", uint32_t(rv));
}
aAnnotation.AppendLiteral(" bytes)\n");
return;
}
}
@ -586,14 +553,6 @@ AnnotateCrashReport(nsIURI* aURI)
annotation.Append(NS_ConvertUTF8toUTF16(spec).get());
annotation.Append('\n');
annotation.AppendLiteral("NS_ERROR_FILE_CORRUPTION reason: ");
if (nsZipArchive::sFileCorruptedReason) {
annotation.Append(NS_ConvertUTF8toUTF16(nsZipArchive::sFileCorruptedReason).get());
annotation.Append('\n');
} else {
annotation.AppendLiteral("(none)\n");
}
// The jar: or file: URL that the sheet's resource: or chrome: URL
// resolves to.
if (scheme.EqualsLiteral("resource")) {
@ -780,7 +739,6 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
}
nsZipArchive::sFileCorruptedReason = nullptr;
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true,
getter_AddRefs(aSheet));
if (NS_FAILED(rv)) {

View File

@ -446,19 +446,14 @@ nsJAR::LoadEntry(const nsACString &aFilename, char** aBuf, uint32_t* aBufLen)
uint64_t len64;
rv = manifestStream->Available(&len64);
if (NS_FAILED(rv)) return rv;
if (len64 >= UINT32_MAX) { // bug 164695
nsZipArchive::sFileCorruptedReason = "nsJAR: invalid manifest size";
return NS_ERROR_FILE_CORRUPTED;
}
NS_ENSURE_TRUE(len64 < UINT32_MAX, NS_ERROR_FILE_CORRUPTED); // bug 164695
uint32_t len = (uint32_t)len64;
buf = (char*)malloc(len+1);
if (!buf) return NS_ERROR_OUT_OF_MEMORY;
uint32_t bytesRead;
rv = manifestStream->Read(buf, len, &bytesRead);
if (bytesRead != len) {
nsZipArchive::sFileCorruptedReason = "nsJAR: manifest too small";
if (bytesRead != len)
rv = NS_ERROR_FILE_CORRUPTED;
}
if (NS_FAILED(rv)) {
free(buf);
return rv;
@ -544,7 +539,6 @@ nsJAR::ParseManifest()
if (more)
{
mParsedManifest = true;
nsZipArchive::sFileCorruptedReason = "nsJAR: duplicate manifests";
return NS_ERROR_FILE_CORRUPTED; // More than one MF file
}
@ -644,10 +638,8 @@ nsJAR::ParseOneFile(const char* filebuf, int16_t aFileType)
curLine.Assign(filebuf, linelen);
if ( ((aFileType == JAR_MF) && !curLine.Equals(JAR_MF_HEADER) ) ||
((aFileType == JAR_SF) && !curLine.Equals(JAR_SF_HEADER) ) ) {
nsZipArchive::sFileCorruptedReason = "nsJAR: invalid manifest header";
((aFileType == JAR_SF) && !curLine.Equals(JAR_SF_HEADER) ) )
return NS_ERROR_FILE_CORRUPTED;
}
//-- Skip header section
do {

View File

@ -58,10 +58,8 @@ nsJARInputStream::InitFile(nsJAR *aJar, nsZipItem *item)
// Must keep handle to filepointer and mmap structure as long as we need access to the mmapped data
mFd = aJar->mZip->GetFD();
mZs.next_in = (Bytef *)aJar->mZip->GetData(item);
if (!mZs.next_in) {
nsZipArchive::sFileCorruptedReason = "nsJARInputStream: !mZs.next_in";
if (!mZs.next_in)
return NS_ERROR_FILE_CORRUPTED;
}
mZs.avail_in = item->Size();
mOutSize = item->RealSize();
mZs.total_out = 0;
@ -268,10 +266,8 @@ nsJARInputStream::ContinueInflate(char* aBuffer, uint32_t aCount,
// now inflate
int zerr = inflate(&mZs, Z_SYNC_FLUSH);
if ((zerr != Z_OK) && (zerr != Z_STREAM_END)) {
nsZipArchive::sFileCorruptedReason = "nsJARInputStream: error while inflating";
if ((zerr != Z_OK) && (zerr != Z_STREAM_END))
return NS_ERROR_FILE_CORRUPTED;
}
*aBytesRead = (mZs.total_out - oldTotalOut);
@ -284,10 +280,8 @@ nsJARInputStream::ContinueInflate(char* aBuffer, uint32_t aCount,
inflateEnd(&mZs);
// stop returning valid data as soon as we know we have a bad CRC
if (mOutCrc != mInCrc) {
nsZipArchive::sFileCorruptedReason = "nsJARInputStream: crc mismatch";
if (mOutCrc != mInCrc)
return NS_ERROR_FILE_CORRUPTED;
}
}
return NS_OK;

View File

@ -444,7 +444,6 @@ nsresult nsZipArchive::ExtractFile(nsZipItem *item, const char *outname,
uint32_t count = 0;
uint8_t* buf = cursor.Read(&count);
if (!buf) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: Read() failed to return a buffer";
rv = NS_ERROR_FILE_CORRUPTED;
break;
} else if (count == 0) {
@ -645,28 +644,22 @@ MOZ_WIN_MEM_TRY_BEGIN
}
}
if (!centralOffset) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: no central offset";
if (!centralOffset)
return NS_ERROR_FILE_CORRUPTED;
}
buf = startp + centralOffset;
// avoid overflow of startp + centralOffset.
if (buf < startp) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: overflow looking for central directory";
if (buf < startp)
return NS_ERROR_FILE_CORRUPTED;
}
//-- Read the central directory headers
uint32_t sig = 0;
while (buf + int32_t(sizeof(uint32_t)) <= endp &&
(sig = xtolong(buf)) == CENTRALSIG) {
// Make sure there is enough data available.
if (endp - buf < ZIPCENTRAL_SIZE) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: central directory too small";
if (endp - buf < ZIPCENTRAL_SIZE)
return NS_ERROR_FILE_CORRUPTED;
}
// Read the fixed-size data.
ZipCentral* central = (ZipCentral*)buf;
@ -679,13 +672,9 @@ MOZ_WIN_MEM_TRY_BEGIN
// Sanity check variable sizes and refuse to deal with
// anything too big: it's likely a corrupt archive.
if (namelen < 1 ||
namelen > kMaxNameLength) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: namelen out of range";
return NS_ERROR_FILE_CORRUPTED;
}
if (buf >= buf + diff || // No overflow
namelen > kMaxNameLength ||
buf >= buf + diff || // No overflow
buf >= endp - diff) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: overflow looking for next item";
return NS_ERROR_FILE_CORRUPTED;
}
@ -708,10 +697,8 @@ MOZ_WIN_MEM_TRY_BEGIN
sig = 0;
} /* while reading central directory records */
if (sig != ENDSIG) {
nsZipArchive::sFileCorruptedReason = "nsZipArchive: unexpected sig";
if (sig != ENDSIG)
return NS_ERROR_FILE_CORRUPTED;
}
// Make the comment available for consumers.
if (endp - buf >= ZIPEND_SIZE) {
@ -1226,6 +1213,3 @@ nsZipItemPtr_base::nsZipItemPtr_base(nsZipArchive *aZip,
return;
}
}
/* static */ const char*
nsZipArchive::sFileCorruptedReason = nullptr;

View File

@ -102,8 +102,6 @@ class nsZipArchive final
~nsZipArchive();
public:
static const char* sFileCorruptedReason;
/** constructing does not open the archive. See OpenArchive() */
nsZipArchive();

View File

@ -233,11 +233,7 @@ FileLocation::Data::Copy(char* aBuf, uint32_t aLen)
aLen, true);
uint32_t readLen;
cursor.Copy(&readLen);
if (readLen != aLen) {
nsZipArchive::sFileCorruptedReason = "FileLocation::Data: insufficient data";
return NS_ERROR_FILE_CORRUPTED;
}
return NS_OK;
return (readLen == aLen) ? NS_OK : NS_ERROR_FILE_CORRUPTED;
}
#endif // !defined(MOZILLA_XPCOMRT_API)
return NS_ERROR_NOT_INITIALIZED;