From: VMware, Inc <> Date: Mon, 15 Oct 2012 04:55:15 +0000 (-0700) Subject: Allow string code be more strict X-Git-Tag: 2012.10.14-874563~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c82b294579a791fa672f76abe34a882b1c87ee2c;p=thirdparty%2Fopen-vm-tools.git Allow string code be more strict Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/services/plugins/dndcp/stringxx/string.cc b/open-vm-tools/services/plugins/dndcp/stringxx/string.cc index 7da54ad74..ea502d87f 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/string.cc +++ b/open-vm-tools/services/plugins/dndcp/stringxx/string.cc @@ -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(mUstr.c_str()), mUstr.bytes()); - } - Util_Zero(const_cast(mUstr.data()), mUstr.bytes()); - mUstr.clear(); -} -#endif // I_LOVE_STRICT_SENSITIVESTRING - - /* *----------------------------------------------------------------------------- * diff --git a/open-vm-tools/services/plugins/dndcp/stringxx/string.hh b/open-vm-tools/services/plugins/dndcp/stringxx/string.hh index df946c058..34b8f83ec 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/string.hh +++ b/open-vm-tools/services/plugins/dndcp/stringxx/string.hh @@ -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);