]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Simple multi-threading fix for wcrtomb
authorVMware, Inc <>
Mon, 22 Mar 2010 22:12:59 +0000 (15:12 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 22 Mar 2010 22:12:59 +0000 (15:12 -0700)
Our printf and msg code uses wcrtomb, but on Windows wcrtomb is
#defined to wctomb, which is not thread-safe. The call sites
think they are getting wcrtomb, and are coded to be thread-safe.
The #define has a comment that wcrtomb is not available in
Windows, but sandbox builds seem to work just fine with the
#define removed, so let's try taking it out.  The resulting
code will still not be completely thread-safe, wcrtomb is
vulnerable if another thread calls setlocale while it is
executing, but callers are supposed to using Unicode_Init,
not setlocale, so let's ignore that problem for now.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/bsdfmt.h

index c8ea6f07db65e0824396b885962652054257fde3..aa31c16d06c8d4833b2f5f2af38de51666465a6d 100644 (file)
@@ -122,16 +122,12 @@ char *BSDFmt_UJToA(uintmax_t, char *, int, int, const char *, int, char,
 
 
 /*
- * Pretend to have wcsrtombs() and wcrtomb().
  * Don't use typedef for mbstate_t because it's actually defined
- * in VS2003/VC7/include/wchar.h, but the functions don't exist.
- * I don't know why, nor do I care.  -- edward
+ * in VS2003/VC7/include/wchar.h -- edward
  */
 
 #ifdef _WIN32
 #define mbstate_t int
-#define wcsrtombs(dest, srcp, n, state) wcstombs(dest, *(srcp), n)
-#define wcrtomb(dest, wc, state) wctomb(dest, wc)
 #endif