--- fontconfig-2.3.95/src/fccache.c.fix-page-size-overflow 2006-08-11 13:34:08.000000000 -0400 +++ fontconfig-2.3.95/src/fccache.c 2006-08-11 13:34:08.000000000 -0400 @@ -39,6 +39,7 @@ #define MACHINE_SIGNATURE_SIZE (9 + 5*20 + 1) /* for when we don't have sysconf: */ #define FC_HARDCODED_PAGESIZE 8192 +#define FC_MAX_PAGESIZE 0xfffff #ifndef O_BINARY #define O_BINARY 0 @@ -1536,10 +1537,28 @@ static char buf[MACHINE_SIGNATURE_SIZE]; int32_t magic = ENDIAN_TEST; char * m = (char *)&magic; + long page_size; - sprintf (buf, "%2x%2x%2x%2x " +#if defined (HAVE_SYSCONF) + page_size = sysconf(_SC_PAGESIZE); +#else + page_size = -1; +#endif + + if (page_size < 0) + page_size = FC_HARDCODED_PAGESIZE; + + if (page_size > FC_MAX_PAGESIZE) + { + page_size = FC_MAX_PAGESIZE; + fprintf (stderr, "system page size is bigger than expected\n"); + } + + snprintf (buf, + sizeof (buf), + "%2x%2x%2x%2x " "%4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x %4x " - "%4x %4x %4x %4x %4x %4x %4x %4x\n", + "%4x %4x %4x %4x %4x %4x %4x%5x\n", m[0], m[1], m[2], m[3], (unsigned int)sizeof (char), (unsigned int)sizeof (char *), @@ -1560,11 +1579,7 @@ (unsigned int)sizeof (FcCharLeaf), (unsigned int)sizeof (FcChar32), (unsigned int)sizeof (FcCache), -#if defined (HAVE_SYSCONF) - (unsigned int)sysconf(_SC_PAGESIZE)); -#else - (unsigned int)FC_HARDCODED_PAGESIZE); -#endif + (unsigned int)page_size); return buf; }