diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cd.def | 1 | ||||
-rw-r--r-- | src/cd_util.c | 14 | ||||
-rw-r--r-- | src/drv/cdcgm.c | 2 | ||||
-rw-r--r-- | src/drv/cddgn.c | 2 | ||||
-rw-r--r-- | src/gdiplus/cdwclpp.cpp | 9 | ||||
-rw-r--r-- | src/gdk/cdgdkclp.c | 11 | ||||
-rw-r--r-- | src/win32/cdwclp.c | 24 | ||||
-rw-r--r-- | src/x11/cdxclp.c | 11 |
8 files changed, 46 insertions, 28 deletions
@@ -394,6 +394,7 @@ EXPORTS cdfCanvasTransformPoint cdRound cdStrDup + cdStrTmpFileName cdInitContextPlusList cdGetContextPlus diff --git a/src/cd_util.c b/src/cd_util.c index 20e9a46..e58900a 100644 --- a/src/cd_util.c +++ b/src/cd_util.c @@ -493,3 +493,17 @@ int cdGetFontFileName(const char* font, char* filename) return 1; } + +int cdStrTmpFileName(char* filename) +{ +#ifdef WIN32 + char tmpPath[10240]; + if (GetTempPath(10240, tmpPath)==0) + return 0; + if (GetTempFileName(tmpPath, "~cd", 0, filename)==0) + return 0; + return 1; +#else + return tmpnam(filename)!=NULL; +#endif +} diff --git a/src/drv/cdcgm.c b/src/drv/cdcgm.c index 19f6ad7..28624d0 100644 --- a/src/drv/cdcgm.c +++ b/src/drv/cdcgm.c @@ -26,7 +26,7 @@ struct _cdCtxCanvas cdCanvas* canvas; CGM *cgm; - char filename[256]; /* Arquivo CGM */ + char filename[10240]; /* Arquivo CGM */ int codificacao; /* Codificacao */ int vdc_int_prec; diff --git a/src/drv/cddgn.c b/src/drv/cddgn.c index dd049fd..e0c497b 100644 --- a/src/drv/cddgn.c +++ b/src/drv/cddgn.c @@ -1583,7 +1583,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) { FILE *seed=NULL; char *cd_dir = getenv("CDDIR"); - static char newfilename[512]; + static char newfilename[10240]; if(cd_dir == NULL) cd_dir = "."; diff --git a/src/gdiplus/cdwclpp.cpp b/src/gdiplus/cdwclpp.cpp index 0e3c5ea..2d1c7e6 100644 --- a/src/gdiplus/cdwclpp.cpp +++ b/src/gdiplus/cdwclpp.cpp @@ -146,12 +146,11 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) if (wtype == -1) { - char filename[1024]; - char tmpPath[512]; - char str[1024]; + char filename[10240]; + char str[10240]; - GetTempPath(512, tmpPath); - GetTempFileName(tmpPath, "~cd", 0, filename); + if (!cdStrTmpFileName(filename)) + return; sprintf(str, "%s %s", filename, strsize); cdcreatecanvasMF(canvas, str); diff --git a/src/gdk/cdgdkclp.c b/src/gdk/cdgdkclp.c index 16eb1c7..c6557b9 100644 --- a/src/gdk/cdgdkclp.c +++ b/src/gdk/cdgdkclp.c @@ -50,7 +50,7 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas) static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data) { - char filename[1024]; + char filename[10240]; int dwSize; FILE* file; GdkAtom* buffer; @@ -59,7 +59,9 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void if(!buffer) return CD_ERROR; - tmpnam(filename); + if (!cdStrTmpFileName(filename)) + return CD_ERROR; + file = fopen(filename, "w"); fwrite(buffer, dwSize, 1, file); fclose(file); @@ -75,7 +77,7 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void static void cdcreatecanvas(cdCanvas* canvas, void *data) { - char tmpPath[512]; + char tmpPath[10240]; char* str = (char*)data; GtkClipboard* clp = NULL; @@ -93,7 +95,8 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) return; str++; - tmpnam(tmpPath); + if (!cdStrTmpFileName(tmpPath)) + return; strcat(tmpPath, " "); strcat(tmpPath, str); diff --git a/src/win32/cdwclp.c b/src/win32/cdwclp.c index a62e9e8..60c29e0 100644 --- a/src/win32/cdwclp.c +++ b/src/win32/cdwclp.c @@ -36,8 +36,7 @@ Interpreta os dados do clipboard, seja metafile ou bitmap. */ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data) { - char tmpPath[512]; - char filename[1024]; + char filename[10240]; HANDLE hFile; DWORD dwSize, nBytesWrite; int err; @@ -48,8 +47,8 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void { HANDLE Handle; - GetTempPath(512, tmpPath); - GetTempFileName(tmpPath, "~cd", 0, filename); + if (!cdStrTmpFileName(filename)) + return CD_ERROR; OpenClipboard(NULL); Handle = GetClipboardData(CF_TEXT); @@ -82,8 +81,8 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void { HENHMETAFILE Handle; - GetTempPath(512, tmpPath); - GetTempFileName(tmpPath, "~cd", 0, filename); + if (!cdStrTmpFileName(filename)) + return CD_ERROR; OpenClipboard(NULL); Handle = (HENHMETAFILE)GetClipboardData(CF_ENHMETAFILE); @@ -119,8 +118,8 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void HANDLE Handle; METAFILEPICT* lpMFP; - GetTempPath(512, tmpPath); - GetTempFileName(tmpPath, "~cd", 0, filename); + if (!cdStrTmpFileName(filename)) + return CD_ERROR; OpenClipboard(NULL); Handle = GetClipboardData(CF_METAFILEPICT); @@ -476,12 +475,11 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) if (wtype == -1) { - char filename[1024]; - char tmpPath[512]; - char str[1024]; + char filename[10240]; + char str[10240]; - GetTempPath(512, tmpPath); - GetTempFileName(tmpPath, "~cd", 0, filename); + if (!cdStrTmpFileName(filename)) + return; sprintf(str, "%s %s", filename, strsize); cdcreatecanvasMF(canvas, str); diff --git a/src/x11/cdxclp.c b/src/x11/cdxclp.c index a2d1b6b..9363491 100644 --- a/src/x11/cdxclp.c +++ b/src/x11/cdxclp.c @@ -49,7 +49,7 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas) static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data) { - char filename[1024]; + char filename[10240]; char* buffer; int dwSize; FILE* file; @@ -58,7 +58,9 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void if (!buffer) return CD_ERROR; - tmpnam(filename); + if (!cdStrTmpFileName(filename)) + return CD_ERROR; + file = fopen(filename, "w"); fwrite(buffer, dwSize, 1, file); fclose(file); @@ -74,7 +76,7 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void static void cdcreatecanvas(cdCanvas* canvas, void *data) { - char tmpPath[512]; + char tmpPath[10240]; char* str = (char*)data; Display* dpy = NULL; @@ -96,7 +98,8 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) return; str++; - tmpnam(tmpPath); + if (!cdStrTmpFileName(tmpPath)) + return; strcat(tmpPath, " "); strcat(tmpPath, str); |