Alexandre Julliard : include: Disallow wcsncpy() in Wine, similarly to strncpy().
Alexandre Julliard
julliard at winehq.org
Tue May 4 16:23:35 CDT 2021
Module: wine
Branch: master
Commit: b35404aa61bf9d5c95ba9b51adb57df7cec1827b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b35404aa61bf9d5c95ba9b51adb57df7cec1827b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue May 4 21:23:01 2021 +0200
include: Disallow wcsncpy() in Wine, similarly to strncpy().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/msvcrt.h | 1 +
dlls/msvcrt/tests/string.c | 1 +
dlls/ntdll/wcstring.c | 1 +
include/winbase.h | 4 +++-
4 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 8f6ee08ef2a..669d8c29a98 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -31,6 +31,7 @@
#include "windef.h"
#include "winbase.h"
#undef strncpy
+#undef wcsncpy
extern BOOL sse2_supported DECLSPEC_HIDDEN;
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index b236301218f..6bf3b6e775d 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -33,6 +33,7 @@
/* make it use a definition from string.h */
#undef strncpy
+#undef wcsncpy
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c
index eee856b21d0..a727e4defac 100644
--- a/dlls/ntdll/wcstring.c
+++ b/dlls/ntdll/wcstring.c
@@ -241,6 +241,7 @@ int __cdecl wcsncmp( LPCWSTR str1, LPCWSTR str2, size_t n )
/*********************************************************************
* wcsncpy (NTDLL.@)
*/
+#undef wcsncpy
LPWSTR __cdecl wcsncpy( LPWSTR s1, LPCWSTR s2, size_t n )
{
WCHAR *ret = s1;
diff --git a/include/winbase.h b/include/winbase.h
index 5e35c31a3b7..2928385bde6 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2888,9 +2888,11 @@ static inline LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
return strcat( dst, src );
}
-/* strncpy doesn't do what you think, don't use it */
+/* strncpy/wcsncpy don't do what you think, don't use them */
#undef strncpy
+#undef wcsncpy
#define strncpy(d,s,n) error do_not_use_strncpy_use_lstrcpynA_or_memcpy_instead
+#define wcsncpy(d,s,n) error do_not_use_wcsncpy_use_lstrcpynW_or_memcpy_instead
#endif /* !defined(__WINESRC__) || defined(WINE_NO_INLINE_STRING) */
More information about the wine-cvs
mailing list