changeset 60:7c92dbd4cc3a draft

fix unsafe string handling in wxGetTranslation git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@73 1a98c847-1fd6-4fd8-948a-caf3550aa51b
author s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
date Sun, 28 Feb 2010 15:00:32 +0000
parents 3ad9843a10ed
children 1aba4fcff3e0
files makefile.vc serialize.h util.cpp
diffstat 3 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/makefile.vc
+++ b/makefile.vc
@@ -36,7 +36,7 @@
 
 
 .cpp{obj}.obj:
-	cl $(CFLAGS) /Fo$@ %s
+    cl $(CFLAGS) /Fo$@ %s
 
 obj\util.obj: $(HEADERS)
 
@@ -59,10 +59,10 @@
 obj\uibase.obj: $(HEADERS)
 
 obj\sha.obj: sha.cpp sha.h
-	cl $(CFLAGS) /O2 /Fo$@ %s
+    cl $(CFLAGS) /O2 /Fo$@ %s
 
 obj\ui.res: ui.rc  rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
-	rc $(INCLUDEPATHS) $(WXDEFS) /Fo$@ %s
+    rc $(INCLUDEPATHS) $(WXDEFS) /Fo$@ %s
 
 OBJS= \
     obj\util.obj \
@@ -75,11 +75,11 @@
     obj\init.obj
 
 bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\sha.obj obj\ui.res
-	link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(LIBS)
+    link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(LIBS)
 
 
 .cpp{obj\nogui}.obj:
-	cl $(CFLAGS) /DwxUSE_GUI=0 /Fo$@ %s
+    cl $(CFLAGS) /DwxUSE_GUI=0 /Fo$@ %s
 
 obj\nogui\util.obj: $(HEADERS)
 
@@ -98,10 +98,10 @@
 obj\nogui\init.obj: $(HEADERS)
 
 bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\sha.obj obj\ui.res
-	link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
+    link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
 
 
 clean:
-	-del /Q obj\*
-	-del *.ilk
-	-del *.pdb
+    -del /Q obj\*
+    -del *.ilk
+    -del *.pdb
--- a/serialize.h
+++ b/serialize.h
@@ -20,7 +20,7 @@
 class CAutoFile;
 
 static const int VERSION = 207;
-static const char* pszSubVer = ".0";
+static const char* pszSubVer = ".1";
 
 
 
--- a/util.cpp
+++ b/util.cpp
@@ -445,17 +445,17 @@
             return (*mi).second;
 
         // wxWidgets translation
-        const char* pszTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str();
+        wxString strTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8));
 
         // We don't cache unknown strings because caller might be passing in a
         // dynamic string and we would keep allocating memory for each variation.
-        if (strcmp(pszEnglish, pszTranslated) == 0)
+        if (strcmp(pszEnglish, strTranslated.utf8_str()) == 0)
             return pszEnglish;
 
         // Add to cache, memory doesn't need to be freed.  We only cache because
         // we must pass back a pointer to permanently allocated memory.
-        char* pszCached = new char[strlen(pszTranslated)+1];
-        strcpy(pszCached, pszTranslated);
+        char* pszCached = new char[strlen(strTranslated.utf8_str())+1];
+        strcpy(pszCached, strTranslated.utf8_str());
         mapCache[pszEnglish] = pszCached;
         return pszCached;
     }