diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 615217b66a8..ecef714b822 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -966,7 +966,8 @@ PRBool ReadSectionHeader(nsManifestLineReader& reader, const char *token) *p = 0; char* values[1]; - if(2 != reader.ParseLine(values, 1)) + int lengths[1]; + if(2 != reader.ParseLine(values, lengths, 1)) break; // ignore the leading '[' @@ -1059,10 +1060,11 @@ nsComponentManagerImpl::ReadPersistentRegistry() if(!reader.NextLine()) goto out; - char* values[6]; + char* values[6]; + int lengths[6]; // VersionLiteral,major,minor - if(3 != reader.ParseLine(values, 3)) + if(3 != reader.ParseLine(values, lengths, 3)) goto out; // VersionLiteral @@ -1086,7 +1088,7 @@ nsComponentManagerImpl::ReadPersistentRegistry() break; //name,last_modification_date - if(2 != reader.ParseLine(values, 2)) + if(2 != reader.ParseLine(values, lengths, 2)) break; PRInt64 a = nsCRT::atoll(values[1]); @@ -1107,7 +1109,7 @@ nsComponentManagerImpl::ReadPersistentRegistry() break; // cid,contract_id,type,class_name,inproc_server - if(5 != reader.ParseLine(values, 5)) + if(5 != reader.ParseLine(values, lengths, 5)) break; nsCID aClass; @@ -1148,7 +1150,7 @@ nsComponentManagerImpl::ReadPersistentRegistry() break; //contractID,cid - if(2 != reader.ParseLine(values, 2)) + if(2 != reader.ParseLine(values, lengths, 2)) break; nsCID aClass; @@ -1185,7 +1187,7 @@ nsComponentManagerImpl::ReadPersistentRegistry() break; //type,name,value - if(3 != reader.ParseLine(values, 3)) + if(3 != reader.ParseLine(values, lengths, 3)) break; catman->AddCategoryEntry(values[0], diff --git a/mozilla/xpcom/ds/nsManifestLineReader.h b/mozilla/xpcom/ds/nsManifestLineReader.h index a5cd98d8f0a..e80e493016d 100644 --- a/mozilla/xpcom/ds/nsManifestLineReader.h +++ b/mozilla/xpcom/ds/nsManifestLineReader.h @@ -78,24 +78,30 @@ public: return PR_FALSE; } - int ParseLine(char** chunks, int maxChunks) + int ParseLine(char** chunks, int* lengths, int maxChunks) { NS_ASSERTION(mCur && maxChunks && chunks, "bad call to ParseLine"); int found = 0; chunks[found++] = mCur; - + if(found < maxChunks) { + char *lastchunk = mCur; + int *lastlength = lengths; for(char* cur = mCur; *cur; cur++) { if(*cur == ',') { *cur = 0; - chunks[found++] = cur+1; + // always fill in the previous chunk's length + *lastlength++ = cur - lastchunk; + chunks[found++] = lastchunk = cur+1; if(found == maxChunks) break; } } + // crazy pointer math - calculate the length of the final chunk + *lastlength = (mCur + mLength) - lastchunk; } return found; } diff --git a/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp b/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp index a9d54b5e1ca..64639be5766 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp +++ b/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp @@ -87,11 +87,11 @@ void xptiInterfaceInfo::DEBUG_ShutdownNotification() // static xptiInterfaceEntry* xptiInterfaceEntry::NewEntry(const char* name, + int nameLength, const nsID& iid, const xptiTypelib& typelib, xptiWorkingSet* aWorkingSet) { - size_t nameLength = PL_strlen(name); void* place = XPT_MALLOC(aWorkingSet->GetStructArena(), sizeof(xptiInterfaceEntry) + nameLength); if(!place) diff --git a/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp b/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp index e305a3f23a2..41e86ef010d 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp +++ b/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp @@ -1306,7 +1306,8 @@ xptiInterfaceInfoManager::VerifyAndAddEntryIfNew(xptiWorkingSet* aWorkingSet, // Build a new xptiInterfaceEntry object and hook it up. - entry = xptiInterfaceEntry::NewEntry(iface->name, iface->iid, + entry = xptiInterfaceEntry::NewEntry(iface->name, strlen(iface->name), + iface->iid, typelibRecord, aWorkingSet); if(!entry) { diff --git a/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp b/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp index 612db5883d7..f2a9e80e3f2 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp +++ b/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp @@ -360,7 +360,8 @@ PRBool ReadSectionHeader(nsManifestLineReader& reader, *p = 0; char* values[2]; - if(2 != reader.ParseLine(values, 2)) + int lengths[2]; + if(2 != reader.ParseLine(values, lengths, 2)) break; // ignore the leading '[' @@ -395,6 +396,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, int dir; int flags; char* values[6]; // 6 is currently the max items we need to parse + int lengths[6]; PRUint32 size32; PRInt64 size; PRInt64 date; @@ -427,7 +429,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,VersionLiteral,major,minor - if(4 != reader.ParseLine(values, 4)) + if(4 != reader.ParseLine(values, lengths, 4)) goto out; // index @@ -452,7 +454,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,AppDirLiteral,directoryname - if(3 != reader.ParseLine(values, 3)) + if(3 != reader.ParseLine(values, lengths, 3)) goto out; // index @@ -493,7 +495,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,directoryname - if(2 != reader.ParseLine(values, 2)) + if(2 != reader.ParseLine(values, lengths, 2)) goto out; // index @@ -524,7 +526,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,filename,dirIndex,dilesSize,filesDate - if(5 != reader.ParseLine(values, 5)) + if(5 != reader.ParseLine(values, lengths, 5)) goto out; // index @@ -576,7 +578,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,filename - if(2 != reader.ParseLine(values, 2)) + if(2 != reader.ParseLine(values, lengths, 2)) goto out; // index @@ -611,7 +613,7 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, goto out; // index,interfaceName,iid,fileIndex,zipIndex,flags - if(6 != reader.ParseLine(values, 6)) + if(6 != reader.ParseLine(values, lengths, 6)) goto out; // index @@ -648,7 +650,8 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, else typelibRecord.Init(fileIndex, zipItemIndex); - entry = xptiInterfaceEntry::NewEntry(values[1], iid, typelibRecord, + entry = xptiInterfaceEntry::NewEntry(values[1], lengths[1], + iid, typelibRecord, aWorkingSet); if(!entry) goto out; diff --git a/mozilla/xpcom/reflect/xptinfo/src/xptiprivate.h b/mozilla/xpcom/reflect/xptinfo/src/xptiprivate.h index 9bb3a54cace..7fcb6b8e2b8 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/xptiprivate.h +++ b/mozilla/xpcom/reflect/xptinfo/src/xptiprivate.h @@ -531,6 +531,7 @@ class xptiInterfaceEntry { public: static xptiInterfaceEntry* NewEntry(const char* name, + int nameLength, const nsID& iid, const xptiTypelib& typelib, xptiWorkingSet* aWorkingSet);