Bug 534353: Copy the correct string data to the EOT header name fields. r=jdaggett

This commit is contained in:
Jonathan Kew 2009-12-20 17:52:57 +00:00
parent 6d706b85f8
commit 9cf092266b

View File

@ -1824,22 +1824,22 @@ gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
PRUint32 nameoff = names[i].offset; // offset from base of string storage PRUint32 nameoff = names[i].offset; // offset from base of string storage
// sanity check the name string location // sanity check the name string location
if (PRUint64(nameOffset) + PRUint64(nameStringsBase) + PRUint64(nameoff) if (PRUint64(nameOffset) + PRUint64(nameStringsBase) +
+ PRUint64(namelen) > dataLength) { PRUint64(nameoff) + PRUint64(namelen) > dataLength) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
strOffset = nameOffset + nameStringsBase + nameoff + namelen;
// output 2-byte str size strOffset = nameOffset + nameStringsBase + nameoff;
// output 2-byte str size
strLen = namelen & (~1); // UTF-16 string len must be even strLen = namelen & (~1); // UTF-16 string len must be even
*((PRUint16*) eotEnd) = PRUint16(strLen); *((PRUint16*) eotEnd) = PRUint16(strLen);
eotEnd += 2; eotEnd += 2;
// length is number of UTF-16 chars, not bytes // length is number of UTF-16 chars, not bytes
CopySwapUTF16(reinterpret_cast<const PRUint16*>(aFontData + strOffset), CopySwapUTF16(reinterpret_cast<const PRUint16*>(aFontData + strOffset),
reinterpret_cast<PRUint16*>(eotEnd), reinterpret_cast<PRUint16*>(eotEnd),
(strLen >> 1)); (strLen >> 1));
eotEnd += strLen; eotEnd += strLen;
// add 2-byte zero padding to the end of each string // add 2-byte zero padding to the end of each string