]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Allow string code be more strict
authorVMware, Inc <>
Mon, 15 Oct 2012 04:55:15 +0000 (21:55 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Fri, 19 Oct 2012 18:32:42 +0000 (11:32 -0700)
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/services/plugins/dndcp/stringxx/string.cc
open-vm-tools/services/plugins/dndcp/stringxx/string.hh

index 7da54ad74f814297115256222ce68dfc4a25f040..ea502d87fba2d5b1ec022f5ed499fb85558af6dd 100644 (file)
@@ -297,12 +297,6 @@ string::string(const char *s,           // IN
  *
  *      Constructor.
  *
- *      XXX: When initializing mUstr, we do a deep copy of the string data
- *      instead of just calling mUstr(s). This is because Glib::ustring is very
- *      smart about sharing storage, and zero_clear is very dumb. Once we get
- *      rid of zero_clear and have a separate sensitive-string class, this can
- *      go back to being simple.
- *
  * Results:
  *      None.
  *
@@ -313,11 +307,7 @@ string::string(const char *s,           // IN
  */
 
 string::string(const Glib::ustring& s) // IN
-#ifdef I_LOVE_STRICT_SENSITIVESTRING
    : mUstr(s),
-#else
-   : mUstr(s.c_str()),
-#endif
      mUtf16Cache(NULL),
      mUtf16Length(npos)
 {
@@ -332,12 +322,6 @@ string::string(const Glib::ustring& s) // IN
  *
  *      Copy constructor.
  *
- *      XXX: When initializing mUstr, we do a deep copy of the string data
- *      instead of just calling mUstr(s). This is because Glib::ustring is very
- *      smart about sharing storage, and zero_clear is very dumb. Once we get
- *      rid of zero_clear and have a separate sensitive-string class, this can
- *      go back to being simple.
- *
  * Results:
  *      None.
  *
@@ -348,11 +332,7 @@ string::string(const Glib::ustring& s) // IN
  */
 
 string::string(const string& s) // IN
-#ifdef I_LOVE_STRICT_SENSITIVESTRING
    : mUstr(s.mUstr),
-#else
-   : mUstr(s.mUstr.c_str()),
-#endif
      mUtf16Cache(NULL),
      mUtf16Length(npos)
 {
@@ -1132,48 +1112,6 @@ string::clear()
 }
 
 
-#ifndef I_LOVE_STRICT_SENSITIVESTRING
-/*
- *-----------------------------------------------------------------------------
- *
- * utf::string::zero_clear --
- *
- *      Zeroes and clears this string.
- *
- *      XXX: This is temporary until we have a separate string class for
- *      passwords.
- *
- * Results:
- *      None
- *
- * Side effects:
- *      None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-string::zero_clear()
-{
-   if (mUtf16Cache != NULL) {
-      Util_ZeroFree(mUtf16Cache,
-                    Unicode_UTF16Strlen(mUtf16Cache) * sizeof *mUtf16Cache);
-      mUtf16Cache = NULL;
-   }
-
-   /*
-    * This is a best effort.  We aren't guaranteed that Glib::ustring doesn't
-    * leave behind any internal copies of the string.
-    */
-   if (mUstr.c_str() != mUstr.data()) {
-      Util_Zero(const_cast<char *>(mUstr.c_str()), mUstr.bytes());
-   }
-   Util_Zero(const_cast<char *>(mUstr.data()), mUstr.bytes());
-   mUstr.clear();
-}
-#endif // I_LOVE_STRICT_SENSITIVESTRING
-
-
 /*
  *-----------------------------------------------------------------------------
  *
index df946c058b88aa82589619850a6db88580e2c177..34b8f83ecacd09beccf67327774fe99215356c6f 100644 (file)
@@ -151,9 +151,6 @@ public:
    string& assign(const string &s);
    void push_back(value_type uc);
    void clear();
-#ifndef I_LOVE_STRICT_SENSITIVESTRING
-   void zero_clear();
-#endif
    string& insert(size_type i, const string& s);
    string& insert(size_type i, size_type n, value_type uc);
    string& insert(iterator p, value_type uc);