diff options
Diffstat (limited to 'Xprint/ps/psout.c')
-rw-r--r-- | Xprint/ps/psout.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Xprint/ps/psout.c b/Xprint/ps/psout.c index d4a64eacb..f1507d849 100644 --- a/Xprint/ps/psout.c +++ b/Xprint/ps/psout.c @@ -73,13 +73,24 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ +/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.c,v 1.12 2001/12/21 21:02:06 dawes Exp $ */ + +/* + * For XFree86 3.3.3: + * + * As a *quick* way of preventing some buffers overflowing onto the stack, + * they have been made static. There are potential problems with + * PsOutRec.Buf overflowing too which should be investigated as part of a + * review of this code, but that is at least always allocated with malloc + * and shouldn't pose an immediate stack trashing problem. + * + */ #include <stdlib.h> #include "os.h" +#include "Ps.h" #include "psout.h" -PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); - typedef void *voidPtr; typedef struct PsPatRec_ @@ -398,7 +409,7 @@ static void S_OutNum(PsOutPtr self, float num) { int i; - char buf[64]; + static char buf[64]; sprintf(buf, "%.3f", num); for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0'; if( buf[strlen(buf)-1]=='.' ) buf[strlen(buf)-1] = '\0'; @@ -411,7 +422,7 @@ static void S_OutStr(PsOutPtr self, char *txt, int txtl) { int i, k; - char buf[512]; + static char buf[512]; for( i=0,k=0 ; i<txtl ; i++ ) { if( (txt[i]>=' ' && txt[i]<='~') && @@ -948,7 +959,7 @@ void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso) { int i; - char buf[256]; + static char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && siz==self->FontSize ) return; if( self->FontName ) xfree(self->FontName); @@ -968,7 +979,7 @@ void PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso) { int i; - char buf[256]; + static char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; @@ -1170,7 +1181,7 @@ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr) if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; - sprintf(cacheID, "c%di", cache_id); + sprintf(cacheID, "c%ldi", cache_id); S_OutNum(self, (float)x); S_OutNum(self, (float)y); @@ -1203,7 +1214,7 @@ PsOut_BeginImageCache(PsOutPtr self, long cache_id) { char cacheID[10]; - sprintf(cacheID, "/c%di {", cache_id); + sprintf(cacheID, "/c%ldi {", cache_id); S_OutTok(self, cacheID, 0); } /* new */ @@ -1214,7 +1225,7 @@ PsOut_EndImageCache(PsOutPtr self) S_OutTok(self, "}bd", 1); } /* new */ #endif - + void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format) @@ -1477,11 +1488,13 @@ PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type, } self->Patterns[self->NPatterns].tag = tag; self->Patterns[self->NPatterns].type = type; - sprintf(key, "/ %d", (int)tag); + sprintf(key, "/ %ld", (long)tag); switch(type) { case PsTile: key[1] = 't'; break; case PsStip: key[1] = 's'; break; - case PsOpStip: key[1] = 'o'; break; } + case PsOpStip: key[1] = 'o'; break; + default: break; + } S_OutTok(self, key, 0); S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0); S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0); @@ -1522,11 +1535,13 @@ PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type) for( i=0 ; i<self->NPatterns ; i++ ) { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; } if( i>=self->NPatterns ) return; - sprintf(key, " %d", (int)tag); + sprintf(key, " %ld", (long)tag); switch(type) { case PsTile: key[0] = 't'; break; case PsStip: key[0] = 's'; break; - case PsOpStip: key[0] = 'o'; break; } + case PsOpStip: key[0] = 'o'; break; + default: break; + } S_OutTok(self, key, 0); S_OutTok(self, "spt", 1); self->CurColor = 0xFFFFFFFF; @@ -1546,7 +1561,7 @@ PsOut_DownloadType1(PsOutPtr self, char *name, char *fname) { int i; int stt; - char buf[256]; + static char buf[256]; FILE *fp; for( i=0 ; i<self->NDownloads ; i++ ) |