From 0729bc9f5223aeefa6d0bf8573a2ba0634cc1ca6 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Thu, 10 Sep 2009 16:09:55 +0900 Subject: [PATCH] [Win64] Improve the computation of random seed from stack address. --- ChangeLog | 14 ++++++++++++++ src/cff/cffgload.c | 7 ++++--- src/psaux/t1decode.c | 7 ++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 116c2cea2..0f63c43c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-09-10 suzuki toshiya + + [Win64] Improve the computation of random seed from stack address. + + On LLP64 platform, the conversion from pointer to FT_Fixed need + to drop higher 32-bit. Explict casts are required. Reported by + NightStrike from MinGW-w64 project. See + http://lists.gnu.org/archive/html/freetype/2009-09/msg00000.html + + * src/cff/cffgload.c: Convert the pointers to FT_Fixed explicitly. + + * src/psaux/t1decode.c: Ditto. + + 2009-09-03 Werner Lemberg [raster] Improvements for stand-alone mode. diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index a5b3e8413..40fa20b42 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -878,9 +878,10 @@ decoder->read_width = 1; /* compute random seed from stack address of parameter */ - seed = (FT_Fixed)(char*)&seed ^ - (FT_Fixed)(char*)&decoder ^ - (FT_Fixed)(char*)&charstring_base; + seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^ + (FT_PtrDist)(char*)&decoder ^ + (FT_PtrDist)(char*)&charstring_base ) & + FT_ULONG_MAX ) ; seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; if ( seed == 0 ) seed = 0x7384; diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index 733ad5bb7..40fbaca93 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -376,9 +376,10 @@ /* compute random seed from stack address of parameter */ - seed = (FT_Fixed)(char*)&seed ^ - (FT_Fixed)(char*)&decoder ^ - (FT_Fixed)(char*)&charstring_base; + seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^ + (FT_PtrDist)(char*)&decoder ^ + (FT_PtrDist)(char*)&charstring_base ) & + FT_ULONG_MAX ) ; seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; if ( seed == 0 ) seed = 0x7384;