From 57e2b887a0e798ab5ab2921cdeba550f322b000c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 8 Jul 2007 19:06:03 +0000 Subject: [PATCH] removed unsecure wxTmpnam() function (patch by Francesco Montorsi) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47238 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/wxcrt.h | 9 +-------- include/wx/wxcrtbase.h | 16 +++++++--------- src/common/wxcrt.cpp | 16 ---------------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index e6116d0752..99c01b94ea 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -2,7 +2,7 @@ // Name: wx/wxcrt.h // Purpose: Type-safe ANSI and Unicode builds compatible wrappers for // CRT functions -// Author: Joel Farley, Ove Kåven +// Author: Joel Farley, Ove K�ven // Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee, Vaclav Slavik // Created: 1998/06/12 // RCS-ID: $Id$ @@ -703,13 +703,6 @@ inline int wxRemove(const wxString& path) inline int wxRename(const wxString& oldpath, const wxString& newpath) { return wxCRT_Rename(oldpath.fn_str(), newpath.fn_str()); } -// NB: we don't provide wxString/wxCStrData versions of wxTmpnam, because 's' -// is writable -inline char *wxTmpnam(char *s) - { return wxCRT_TmpnamA(s); } -inline wchar_t *wxTmpnam(wchar_t *s) - { return wxCRT_TmpnamW(s); } - extern WXDLLIMPEXP_BASE int wxPuts(const wxString& s); extern WXDLLIMPEXP_BASE int wxFputs(const wxString& s, FILE *stream); extern WXDLLIMPEXP_BASE void wxPerror(const wxString& s); diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h index 6cc5b4b60d..cf590db7c3 100644 --- a/include/wx/wxcrtbase.h +++ b/include/wx/wxcrtbase.h @@ -2,7 +2,7 @@ * Name: wx/wxcrtbase.h * Purpose: Type-safe ANSI and Unicode builds compatible wrappers for * CRT functions - * Author: Joel Farley, Ove Kåven + * Author: Joel Farley, Ove K�ven * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee * Created: 1998/06/12 * RCS-ID: $Id$ @@ -476,14 +476,12 @@ WXDLLIMPEXP_BASE int wxCRT_FputsW(const wchar_t *ch, FILE *stream); WXDLLIMPEXP_BASE int wxCRT_FputcW(wchar_t wc, FILE *stream); #endif -#define wxCRT_TmpnamA tmpnam -#ifdef _ttmpnam - #define wxCRT_TmpnamW _wtmpnam -#endif - -#ifndef wxCRT_TmpnamW -WXDLLIMPEXP_BASE wchar_t *wxCRT_TmpnamW(wchar_t *s); -#endif +/* + NB: tmpnam() is unsafe and thus is not wrapped! + Use other wxWidgets facilities instead: + wxFileName::CreateTempFileName, wxTempFile, or wxTempFileOutputStream +*/ +#define wxTmpnam(x) wxTmpnam_is_insecure_use_wxTempFile_instead #define wxCRT_PerrorA perror #ifdef wxHAVE_TCHAR_SUPPORT diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index e4e5426cf3..6d5c08774d 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -1106,22 +1106,6 @@ int wxCRT_RemoveW(const wchar_t *path) } #endif -#ifndef wxCRT_TmpnamW -wchar_t *wxCRT_TmpnamW(wchar_t *s) -{ - // tmpnam_r() returns NULL if s=NULL, do the same - wxCHECK_MSG( s, NULL, "wxTmpnam must be called with a buffer" ); - -#ifndef L_tmpnam - #define L_tmpnam 1024 -#endif - wxCharBuffer buf(L_tmpnam); - tmpnam(buf.data()); - - wxConvLibc.ToWChar(s, L_tmpnam+1, buf.data()); - return s; -} -#endif // !wxCRT_TmpnamW // ============================================================================ -- 2.47.2