From: VMware, Inc <> Date: Mon, 15 Oct 2012 04:50:52 +0000 (-0700) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2012.10.14-874563~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a0cff4de9c0b59e12548da5ccaac28ea0306469;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . add StrUtil_IsASCII (not used by the OVT code). . other changes in shared code that don't affect open-vm-tools functionality Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/include/sha1.h b/open-vm-tools/lib/include/sha1.h index 769f6f489..fd70f3d1e 100644 --- a/open-vm-tools/lib/include/sha1.h +++ b/open-vm-tools/lib/include/sha1.h @@ -49,6 +49,24 @@ /* for uint32 */ #include "vm_basic_types.h" + +#if defined __APPLE__ && defined USERLEVEL + +/* + * Apple provides basic crypto functions in its system runtime that are + * maintained for both speed and security. Use those instead. + */ + +#include + +#define SHA1_HASH_LEN CC_SHA1_DIGEST_LENGTH +#define SHA1_CTX CC_SHA1_CTX +#define SHA1Init CC_SHA1_Init +#define SHA1Update CC_SHA1_Update +#define SHA1Final CC_SHA1_Final + +#else + /* SHA-1 in C By Steve Reid @@ -90,6 +108,6 @@ void SHA1Update(SHA1_CTX* context, #endif void SHA1Final(unsigned char digest[SHA1_HASH_LEN], SHA1_CTX* context); -void SHA1Transform(uint32 state[5], const unsigned char buffer[64]); +#endif // defined __APPLE__ && defined USERLEVEL #endif // ifndef _SHA1_H_ diff --git a/open-vm-tools/lib/include/strutil.h b/open-vm-tools/lib/include/strutil.h index ebc65739d..7ef7ca22e 100644 --- a/open-vm-tools/lib/include/strutil.h +++ b/open-vm-tools/lib/include/strutil.h @@ -57,6 +57,7 @@ size_t StrUtil_GetLongestLineLength(const char *buf, size_t bufLength); Bool StrUtil_StartsWith(const char *s, const char *prefix); Bool StrUtil_CaselessStartsWith(const char *s, const char *prefix); Bool StrUtil_EndsWith(const char *s, const char *suffix); +Bool StrUtil_IsASCII(const char *s); Bool StrUtil_VDynBufPrintf(struct DynBuf *b, const char *fmt, va_list args); Bool StrUtil_DynBufPrintf(struct DynBuf *b, const char *fmt, ...); diff --git a/open-vm-tools/lib/include/vm_basic_defs.h b/open-vm-tools/lib/include/vm_basic_defs.h index db8fdce8e..3c23d9f44 100644 --- a/open-vm-tools/lib/include/vm_basic_defs.h +++ b/open-vm-tools/lib/include/vm_basic_defs.h @@ -213,8 +213,10 @@ Max(int a, int b) * Wide versions of string constants. */ +#ifndef WSTR #define WSTR_(X) L ## X #define WSTR(X) WSTR_(X) +#endif /* diff --git a/open-vm-tools/lib/include/vm_legal.h b/open-vm-tools/lib/include/vm_legal.h index ed6d161ff..310c59117 100644 --- a/open-vm-tools/lib/include/vm_legal.h +++ b/open-vm-tools/lib/include/vm_legal.h @@ -29,17 +29,32 @@ */ #include "vm_version.h" +#ifndef WSTR +#define WSTR_(x) L ## x +#define WSTR(x) WSTR_(x) +#endif + + +#define COPYRIGHT_YEARS "1998-2012" +#define COPYRIGHT_STRING "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME +#define RIGHT_RESERVED "All rights reserved." /* * Use UTF8_COPYRIGHT_STRING_BASE when the COMPANY_NAME must be separated out * to create a hyperlink. */ -#define COPYRIGHT_YEARS "1998-2012" -#define COPYRIGHT_STRING "Copyright \251 " COPYRIGHT_YEARS " " COMPANY_NAME #define UTF8_COPYRIGHT_STRING_BASE "Copyright \302\251 " COPYRIGHT_YEARS #define UTF8_COPYRIGHT_STRING UTF8_COPYRIGHT_STRING_BASE " " COMPANY_NAME -#define GENERIC_COPYRIGHT_STRING "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME -#define RIGHT_RESERVED "All rights reserved." + +/* + * A UTF-16 version of the copyright string. wchar_t is an + * implementation-defined type, but we can expect it to be UTF-16 on + * Windows. (Only Windows cares about UTF-16 anyway.) + */ +#ifdef _WIN32 +#define UTF16_COPYRIGHT_STRING L"Copyright \x00A9 " WSTR(COPYRIGHT_YEARS) L" " WSTR(COMPANY_NAME) +#endif + /* * Use PATENTS_STRING for showing the patents string in plaintext form. diff --git a/open-vm-tools/lib/misc/sha1.c b/open-vm-tools/lib/misc/sha1.c index cc6303e93..df154eaf0 100644 --- a/open-vm-tools/lib/misc/sha1.c +++ b/open-vm-tools/lib/misc/sha1.c @@ -163,9 +163,11 @@ _SHA1Transform(uint32 state[5], unsigned char buffer[64]) } #ifdef SHA1HANDSOFF -void SHA1Transform(uint32 state[5], const unsigned char buffer[64]) +static void +SHA1Transform(uint32 state[5], const unsigned char buffer[64]) #else -void SHA1Transform(uint32 state[5], unsigned char buffer[64]) +static void +SHA1Transform(uint32 state[5], unsigned char buffer[64]) #endif { #ifdef SHA1HANDSOFF diff --git a/open-vm-tools/lib/misc/strutil.c b/open-vm-tools/lib/misc/strutil.c index 246223b67..6f328b594 100644 --- a/open-vm-tools/lib/misc/strutil.c +++ b/open-vm-tools/lib/misc/strutil.c @@ -33,6 +33,7 @@ #include "strutil.h" #include "str.h" #include "dynbuf.h" +#include "vm_ctype.h" /* @@ -897,6 +898,37 @@ StrUtil_EndsWith(const char *s, // IN } +/* + *----------------------------------------------------------------------------- + * + * StrUtil_IsASCII -- + * + * Results: + * Returns TRUE if the string contains only ASCII characters, FALSE + * otherwise. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +Bool +StrUtil_IsASCII(const char *s) // IN +{ + ASSERT(s != NULL); + + while (*s != '\0') { + if (!CType_IsAscii(*s)) { + return FALSE; + } + s++; + } + + return TRUE; +} + + /* *----------------------------------------------------------------------------- * diff --git a/open-vm-tools/services/plugins/dndcp/stringxx/string.cc b/open-vm-tools/services/plugins/dndcp/stringxx/string.cc index 0df6ffb44..7da54ad74 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/string.cc +++ b/open-vm-tools/services/plugins/dndcp/stringxx/string.cc @@ -312,8 +312,12 @@ string::string(const char *s, // IN *----------------------------------------------------------------------------- */ -string::string(const Glib::ustring &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) { @@ -343,8 +347,12 @@ string::string(const Glib::ustring &s) // IN *----------------------------------------------------------------------------- */ -string::string(const string &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) { @@ -627,30 +635,6 @@ string::empty() } -/* - *----------------------------------------------------------------------------- - * - * utf::string::isASCII -- - * - * Test if every character in the string is in the ASCII range. - * - * Results: - * true if all ASCII, otherwise false. - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -bool -string::isASCII() - const -{ - return mUstr.is_ascii(); -} - - /* *----------------------------------------------------------------------------- * @@ -1148,6 +1132,7 @@ string::clear() } +#ifndef I_LOVE_STRICT_SENSITIVESTRING /* *----------------------------------------------------------------------------- * @@ -1186,6 +1171,7 @@ string::zero_clear() 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 0c1ea516a..df946c058 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/string.hh +++ b/open-vm-tools/services/plugins/dndcp/stringxx/string.hh @@ -128,7 +128,6 @@ public: void swap(string &s); void resize(size_type n, value_type c = '\0'); bool empty() const; - bool isASCII() const; size_type size() const; size_type w_size() const; size_type length() const; @@ -152,7 +151,9 @@ 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);