[tex-live] TeXLive2007: Bug in (Xe)TeX for 64bit and big endianess

Dr. Werner Fink werner at suse.de
Tue May 8 14:00:55 CEST 2007


Hi,

just to be noted, I've detected some pointer issues which
cause XeTeX to fail on e.g. ppc64 and s390x.  The problem
is that a cast from long to int will loose the four lower
bytes due to the natural nature of the memory management 
of big endian systems.  I've attached a patch which fix this
issue and get XeTeX on work on ppc64 and s390x.

Next is that I've found during debugging a lot of mixed
long and int assignments which may also cause trouble
e.g. in high memory loaded ia64 systems due to the large
address spaces for virtual memory handling.  IMHO this
should be fixed overall the source code not only the XeTeX.

One wish I'd like to put here around: is there a way to use
libpoppler instead of xpdf?  This would allow to use the
system libpoppler and reduce any maintenance effort in any
case of a security leak in xpdf/poppler because only the
system libpoppler has to be replaced.  For the current
libpoppler and XeTeX I've to disable the pdftosrc utility
because I've found no way to use this together with libpoppler.

    Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
-------------- next part --------------
--- texk/web2c/xetexdir/XeTeX_ext.c
+++ texk/web2c/xetexdir/XeTeX_ext.c	2007-03-15 10:57:30.000000000 +0100
@@ -288,9 +288,9 @@ input_line_icu(UFILE* f)
 static char* byteBuffer = NULL;
 
 	UInt32		bytesRead = 0;
-	int			i;
+	int		i;
 	UConverter*	cnv;
-	long		outLen;
+	int		outLen;
 	UErrorCode	errorCode = 0;
 
 	if (byteBuffer == NULL)
@@ -392,8 +392,8 @@ linebreaknext()
 	return ubrk_next((UBreakIterator*)brkIter);
 }
 
-long
-getencodingmodeandinfo(long* info)
+int
+getencodingmodeandinfo(int* info)
 {
 	/* \XeTeXinputencoding "enc-name"
 	 *   -> name is packed in |nameoffile| as a C string, starting at [1]
@@ -811,7 +811,7 @@ splitFontName(char* name, char** var, ch
 }
 
 void*
-findnativefont(unsigned char* uname, long scaled_size)
+findnativefont(unsigned char* uname, int scaled_size)
 	/* scaled_size here is in TeX points */
 {
 	void*	rval = 0;
@@ -950,7 +950,6 @@ void
 otgetfontmetrics(void* pEngine, scaled* ascent, scaled* descent, scaled* xheight, scaled* capheight, scaled* slant)
 {
 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
-	long	rval = 0;
 	float	a, d;
 	int		glyphID;
 
@@ -977,7 +976,7 @@ otgetfontmetrics(void* pEngine, scaled* 
 		*capheight = *ascent; /* arbitrary figure if there's no 'X' in the font */
 }
 
-long
+int
 otfontget(int what, void* pEngine)
 {
 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
@@ -995,8 +994,8 @@ otfontget(int what, void* pEngine)
 }
 
 
-long
-otfontget1(int what, void* pEngine, long param)
+int
+otfontget1(int what, void* pEngine, int param)
 {
 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
 	XeTeXFont	fontInst = getFont(engine);
@@ -1013,8 +1012,8 @@ otfontget1(int what, void* pEngine, long
 }
 
 
-long
-otfontget2(int what, void* pEngine, long param1, long param2)
+int
+otfontget2(int what, void* pEngine, int param1, int param2)
 {
 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
 	XeTeXFont	fontInst = getFont(engine);
@@ -1032,8 +1031,8 @@ otfontget2(int what, void* pEngine, long
 }
 
 
-long
-otfontget3(int what, void* pEngine, long param1, long param2, long param3)
+int
+otfontget3(int what, void* pEngine, int param1, int param2, int param3)
 {
 	XeTeXLayoutEngine	engine = (XeTeXLayoutEngine)pEngine;
 	XeTeXFont	fontInst = getFont(engine);
@@ -1138,8 +1137,8 @@ makeXDVGlyphArrayData(void* pNode)
 	return ((char*)cp - xdvbuffer);
 }
 
-long
-makefontdef(long f)
+int
+makefontdef(int f)
 {
 	UInt16	flags = 0;
 	UInt32	variationCount = 0;
@@ -1515,7 +1514,7 @@ measure_native_node(void* pNode, int use
 		void*	glyph_info = 0;
 		static	float*	positions = 0;
 		static	UInt32*	glyphs = 0;
-		static	long	maxGlyphs = 0;
+		static	int	maxGlyphs = 0;
 
 		FixedPoint*	locations;
 		UInt16*		glyphIDs;
@@ -1928,10 +1927,10 @@ atsugetfontmetrics(ATSUStyle style, Fixe
 #endif
 }
 
-long
+int
 atsufontget(int what, ATSUStyle style)
 {
-	long	rval = -1;
+	int	rval = -1;
 
 #ifdef XETEX_MAC
 	ATSUFontID	fontID;
@@ -1966,10 +1965,10 @@ atsufontget(int what, ATSUStyle style)
 	return rval;
 }
 
-long
+int
 atsufontget1(int what, ATSUStyle style, int param)
 {
-	long	rval = -1;
+	int	rval = -1;
 
 #ifdef XETEX_MAC
 	ATSUFontID	fontID;
@@ -2026,10 +2025,10 @@ atsufontget1(int what, ATSUStyle style, 
 	return rval;
 }
 
-long
+int
 atsufontget2(int what, ATSUStyle style, int param1, int param2)
 {
-	long	rval = -1;
+	int	rval = -1;
 
 #ifdef XETEX_MAC
 	ATSUFontID	fontID;
@@ -2063,10 +2062,10 @@ atsufontget2(int what, ATSUStyle style, 
 	return rval;
 }
 
-long
+int
 atsufontgetnamed(int what, ATSUStyle style)
 {
-	long	rval = -1;
+	int	rval = -1;
 
 #ifdef XETEX_MAC
 	ATSUFontID	fontID;
@@ -2090,10 +2089,10 @@ atsufontgetnamed(int what, ATSUStyle sty
 	return rval;
 }
 
-long
+int
 atsufontgetnamed1(int what, ATSUStyle style, int param)
 {
-	long	rval = -1;
+	int	rval = -1;
 
 #ifdef XETEX_MAC
 	ATSUFontID	fontID;
--- texk/web2c/xetexdir/XeTeX_ext.h
+++ texk/web2c/xetexdir/XeTeX_ext.h	2007-03-15 10:57:33.000000000 +0100
@@ -218,11 +218,11 @@ extern "C" {
 	int input_line_icu(unicodefile f);
 	void linebreakstart(int localeStrNum, const UniChar* text, int textLength);
 	int linebreaknext();
-	long getencodingmodeandinfo(long* info);
+	int getencodingmodeandinfo(int* info);
 	void printutf8str(const unsigned char* str, int len);
 	void printchars(const unsigned short* str, int len);
 	void* load_mapping_file(const char* s, const char* e);
-	void* findnativefont(unsigned char* name, long scaled_size);
+	void* findnativefont(unsigned char* name, int scaled_size);
 	void releasefontengine(void* engine, int type_flag);
 
 	/* 'integer' params here are really TeX 'scaled' values, but that typedef isn't available every place this is included */
@@ -236,12 +236,12 @@ extern "C" {
 	integer getnativechardp(int font, int ch);
 	integer getnativecharic(int font, int ch);
 
-	long otfontget(int what, void* engine);
-	long otfontget1(int what, void* engine, long param);
-	long otfontget2(int what, void* engine, long param1, long param2);
-	long otfontget3(int what, void* engine, long param1, long param2, long param3);
+	int otfontget(int what, void* engine);
+	int otfontget1(int what, void* engine, int param);
+	int otfontget2(int what, void* engine, int param1, int param2);
+	int otfontget3(int what, void* engine, int param1, int param2, int param3);
 	int makeXDVGlyphArrayData(void* p);
-	long makefontdef(long f);
+	int makefontdef(int f);
 	int applymapping(void* cnv, const UniChar* txtPtr, int txtLen);
 	void store_justified_native_glyphs(void* node);
 	void measure_native_node(void* node, int use_glyph_metrics);
--- texk/web2c/xetexdir/xetex.h
+++ texk/web2c/xetexdir/xetex.h	2007-03-15 10:34:35.000000000 +0100
@@ -63,8 +63,8 @@ void* getotassemblyptr(int f, int g); /*
 
 #define dviopenout(f)			open_dvi_output(&(f))
 
-#define casttoptr(x)		(void*)(x)
-#define casttointeger(x)	(long)(x)
+#define casttoptr(x)		(void*)(&(x))
+#define casttointeger(x)	(int)(x)
 #define glyphinfobyte(p,k)	((unsigned char*)p)[k]
 #define casttoushort(x)		(unsigned short)(x)
 


More information about the tex-live mailing list