summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cd_private.h1
-rw-r--r--mak.vc9/cdgdk.vcproj2
-rw-r--r--src/cd.def1
-rw-r--r--src/cd_util.c14
-rw-r--r--src/drv/cdcgm.c2
-rw-r--r--src/drv/cddgn.c2
-rw-r--r--src/gdiplus/cdwclpp.cpp9
-rw-r--r--src/gdk/cdgdkclp.c11
-rw-r--r--src/win32/cdwclp.c24
-rw-r--r--src/x11/cdxclp.c11
10 files changed, 48 insertions, 29 deletions
diff --git a/include/cd_private.h b/include/cd_private.h
index 121a000..c85ddbf 100644
--- a/include/cd_private.h
+++ b/include/cd_private.h
@@ -280,6 +280,7 @@ char* cdStrDup(const char* str);
char* cdStrDupN(const char* str, int len);
void cdSetPaperSize(int size, double *w_pt, double *h_pt);
int cdGetFontFileName(const char* font, char* filename);
+int cdStrTmpFileName(char* filename);
void cdCanvasPoly(cdCanvas* canvas, int mode, cdPoint* points, int n);
void cdCanvasGetArcBox(int xc, int yc, int w, int h, double a1, double a2, int *xmin, int *xmax, int *ymin, int *ymax);
diff --git a/mak.vc9/cdgdk.vcproj b/mak.vc9/cdgdk.vcproj
index f253c11..54e2cac 100644
--- a/mak.vc9/cdgdk.vcproj
+++ b/mak.vc9/cdgdk.vcproj
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\include;..\src;..\src\drv;..\src\freetype2;..\src\intcgm;..\src\iup;..\src\sim;&quot;d:\lng\gtk\include\atk-1.0&quot;;d:\lng\gtk\include\cairo;&quot;d:\lng\gtk\include\glib-2.0&quot;;&quot;d:\lng\gtk\include\pango-1.0&quot;;&quot;d:\lng\gtk\include\gtk-2.0&quot;;&quot;d:\lng\gtk\lib\glib-2.0\include&quot;;&quot;d:\lng\gtk\lib\gtk-2.0\include&quot;"
+ AdditionalIncludeDirectories="..\include;..\src;..\src\drv;..\src\freetype2;..\src\intcgm;..\src\iup;..\src\sim;&quot;d:\lng\gtk\include\atk-1.0&quot;;d:\lng\gtk\include\cairo;&quot;d:\lng\gtk\include\glib-2.0&quot;;&quot;d:\lng\gtk\include\pango-1.0&quot;;&quot;d:\lng\gtk\include\gtk-2.0&quot;;&quot;d:\lng\gtk\include\gdk-pixbuf-2.0&quot;;&quot;d:\lng\gtk\lib\glib-2.0\include&quot;;&quot;d:\lng\gtk\lib\gtk-2.0\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;CD_NO_OLD_INTERFACE;FT2_BUILD_LIBRARY;_CRT_SECURE_NO_DEPRECATE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
diff --git a/src/cd.def b/src/cd.def
index d1b1334..038185a 100644
--- a/src/cd.def
+++ b/src/cd.def
@@ -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);