Specify the maximum signature buffer size to prevent unwanted overflow.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29338 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2009-02-27 21:11:05 +00:00
parent 3b40448410
commit 8bf58c3b53
3 changed files with 7 additions and 4 deletions

View File

@ -52,8 +52,9 @@ FontCache::Default()
FontCacheEntry*
FontCache::FontCacheEntryFor(const ServerFont& font)
{
char signature[512];
FontCacheEntry::GenerateSignature(signature, font);
static const size_t signatureSize = 512;
char signature[signatureSize];
FontCacheEntry::GenerateSignature(signature, signatureSize, font);
AutoReadLocker readLocker(this);

View File

@ -217,7 +217,8 @@ FontCacheEntry::GetKerning(uint16 glyphCode1, uint16 glyphCode2,
// GenerateSignature
/*static*/ void
FontCacheEntry::GenerateSignature(char* signature, const ServerFont& font)
FontCacheEntry::GenerateSignature(char* signature, size_t signatureSize,
const ServerFont& font)
{
glyph_rendering renderingType = _RenderTypeFor(font);
@ -226,7 +227,7 @@ FontCacheEntry::GenerateSignature(char* signature, const ServerFont& font)
bool hinting = font.Hinting();
uint8 averageWeight = gSubpixelAverageWeight;
sprintf(signature, "%ld,%u,%d,%d,%.1f,%d,%d",
snprintf(signature, signatureSize, "%ld,%u,%d,%d,%.1f,%d,%d",
font.GetFamilyAndStyle(), charMap,
font.Face(), int(renderingType), font.Size(), hinting, averageWeight);
}

View File

@ -93,6 +93,7 @@ class FontCacheEntry : public MultiLocker, public Referenceable {
uint16 glyphCode2, double* x, double* y);
static void GenerateSignature(char* signature,
size_t signatureSize,
const ServerFont& font);
// private to FontCache class: