Index: lib/ms_fnmatch.c =================================================================== --- lib/ms_fnmatch.c (revision 4030) +++ lib/ms_fnmatch.c (working copy) @@ -167,9 +167,18 @@ } } - pstrcpy_wa(p, pattern); - pstrcpy_wa(s, string); + if (push_ucs2(NULL, p, pattern, sizeof(p), STR_TERMINATE) == (size_t)-1) { + /* Not quite the right answer, but finding the right one + under this failure case is expensive, and it's pretty close */ + return -1; + } + if (push_ucs2(NULL, s, string, sizeof(s), STR_TERMINATE) == (size_t)-1) { + /* Not quite the right answer, but finding the right one + under this failure case is expensive, and it's pretty close */ + return -1; + } + if (protocol <= PROTOCOL_LANMAN2) { /* for older negotiated protocols it is possible to Index: lib/util_unistr.c =================================================================== --- lib/util_unistr.c (revision 4030) +++ lib/util_unistr.c (working copy) @@ -708,16 +708,6 @@ The char* arguments must NOT be multibyte - to be completely sure of this only pass string constants */ - -void pstrcpy_wa(smb_ucs2_t *dest, const char *src) -{ - int i; - for (i=0;i