]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Mon, 15 Oct 2012 04:50:52 +0000 (21:50 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Fri, 19 Oct 2012 18:32:40 +0000 (11:32 -0700)
. 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 <dtor@vmware.com>
open-vm-tools/lib/include/sha1.h
open-vm-tools/lib/include/strutil.h
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/lib/include/vm_legal.h
open-vm-tools/lib/misc/sha1.c
open-vm-tools/lib/misc/strutil.c
open-vm-tools/services/plugins/dndcp/stringxx/string.cc
open-vm-tools/services/plugins/dndcp/stringxx/string.hh

index 769f6f4894bee3b07337bf6b266b1ad306039363..fd70f3d1ee7d7a6db2b4ded8e1a5c379b1caa28c 100644 (file)
 /* 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 <CommonCrypto/CommonDigest.h>
+
+#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 <steve@edmweb.com>
@@ -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_
index ebc65739d060641e3f26715d7679c8150c579495..7ef7ca22e1572cd1430e8fd7c013700006abff8a 100644 (file)
@@ -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, ...);
index db8fdce8ee6c71c78ad01b59080edbf301120a15..3c23d9f44341ef99dee516e5a9e9babba073b188 100644 (file)
@@ -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
 
 
 /*
index ed6d161ffec217fc2cfd2109d5fb6cf00899a756..310c59117444fbdf3f7960227923e7b0abdac623 100644 (file)
  */
 #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.
index cc6303e93521f6abb4915fd4b7727bb80501cad9..df154eaf023fa2b113089713e4628236901e8e53 100644 (file)
@@ -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
index 246223b67ae3a076e7f9742138af9cbb4efb3720..6f328b594a50cbb1530432f711dac34734ededfc 100644 (file)
@@ -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;
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *
index 0df6ffb44104ae754f6ea54bac9e82463ebe4580..7da54ad74f814297115256222ce68dfc4a25f040 100644 (file)
@@ -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<char *>(mUstr.data()), mUstr.bytes());
    mUstr.clear();
 }
+#endif // I_LOVE_STRICT_SENSITIVESTRING
 
 
 /*
index 0c1ea516ad20e89acaf4d84cc3b0a0aa19785732..df946c058b88aa82589619850a6db88580e2c177 100644 (file)
@@ -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);