From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:26:17 +0000 (-0700) Subject: Switch utf::string from g_utf8_validate to Unicode_IsBufferValid. X-Git-Tag: 2013.09.16-1328054~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c693664f4424ce0cf090b9c85df210c8e47467;p=thirdparty%2Fopen-vm-tools.git Switch utf::string from g_utf8_validate to Unicode_IsBufferValid. In the version of glib we currently use g_utf8_validate rejects strings containing the non-characters U+FFFE and U+FFFF. This was marked as a bug and resolved (see https://bugzilla.gnome.org/show_bug.cgi?id=694669) but until that is released we need a workaround. Our internal UTF-8 validation routine accepts these characters as valid so use that instead. 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 ea502d87f..c816341ee 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/string.cc +++ b/open-vm-tools/services/plugins/dndcp/stringxx/string.cc @@ -2049,9 +2049,11 @@ string::end() bool Validate(const Glib::ustring& s) // IN { - bool isValid = s.validate(); + bool isValid = Unicode_IsBufferValid(s.c_str(), s.bytes(), + STRING_ENCODING_UTF8); if (!isValid) { - char *escaped = Unicode_EscapeBuffer(s.c_str(), -1, STRING_ENCODING_UTF8); + char *escaped = Unicode_EscapeBuffer(s.c_str(), s.bytes(), + STRING_ENCODING_UTF8); Warning("Invalid UTF-8 string: \"%s\"\n", escaped); free(escaped); }