From: VMware, Inc <> Date: Mon, 22 Mar 2010 22:12:59 +0000 (-0700) Subject: Simple multi-threading fix for wcrtomb X-Git-Tag: 2010.03.20-243334~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6f485cf75fac883716317280a2c293fd5f66a32;p=thirdparty%2Fopen-vm-tools.git Simple multi-threading fix for wcrtomb 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 --- diff --git a/open-vm-tools/lib/include/bsdfmt.h b/open-vm-tools/lib/include/bsdfmt.h index c8ea6f07d..aa31c16d0 100644 --- a/open-vm-tools/lib/include/bsdfmt.h +++ b/open-vm-tools/lib/include/bsdfmt.h @@ -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