diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 4e815170679..7ee6161ad4d 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -2669,6 +2669,7 @@ static BOOL ParseStringSecurityDescriptorToSecurityDescriptor( WCHAR tok[MAX_PATH]; LPCWSTR lptoken; LPBYTE lpNext = NULL; + DWORD len; *cBytes = 0; @@ -2696,7 +2697,9 @@ static BOOL ParseStringSecurityDescriptorToSecurityDescriptor( if (*lptoken) lptoken--; - strncpyW(tok, StringSecurityDescriptor, lptoken - StringSecurityDescriptor); + len = lptoken - StringSecurityDescriptor; + memcpy( tok, StringSecurityDescriptor, len * sizeof(WCHAR) ); + tok[len] = 0; switch (toktype) { diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c index 377d19ac646..9edc4de634b 100644 --- a/dlls/ntdll/time.c +++ b/dlls/ntdll/time.c @@ -866,10 +866,12 @@ static int TIME_GetTimeZoneInfoFromReg(LPTIME_ZONE_INFORMATION tzinfo) RtlInitUnicodeString( &nameW, valkey );\ if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, KpInfo,\ sizeof(buf), &size )) { \ - strncpyW( tofield, (WCHAR*) KpInfo->Data, \ - sizeof( tofield) / sizeof(WCHAR) ); \ + size_t len = (strlenW( (WCHAR*)KpInfo->Data ) + 1) * sizeof(WCHAR); \ + if (len > sizeof(tofield)) len = sizeof(tofield); \ + memcpy( tofield, KpInfo->Data, len ); \ + tofield[(len/sizeof(WCHAR))-1] = 0; \ } - + GTZIFR_N( TZStandardStartW, tzinfo->StandardDate) GTZIFR_N( TZDaylightStartW, tzinfo->DaylightDate) GTZIFR_N( TZBiasW, tzinfo->Bias) diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c index be364ec7752..93ba2b6eeb3 100644 --- a/dlls/ntdll/wcstring.c +++ b/dlls/ntdll/wcstring.c @@ -182,7 +182,10 @@ INT __cdecl NTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n ) */ LPWSTR __cdecl NTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n ) { - return strncpyW( s1, s2, n ); + WCHAR *ret = s1; + while (n-- > 0) if (!(*s1++ = *s2++)) break; + while (n-- > 0) *s1++ = 0; + return ret; } diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 2e777c856b9..3ed3f9d5efe 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -864,8 +864,7 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC } len = lastpos - firstpos - 1; - strncpyW(lpszCurrentDirectory, &lpszResponseBuffer[firstpos+1], - len < *lpdwCurrentDirectory ? len : *lpdwCurrentDirectory); + lstrcpynW(lpszCurrentDirectory, &lpszResponseBuffer[firstpos+1], *lpdwCurrentDirectory); HeapFree(GetProcessHeap(), 0, lpszResponseBuffer); *lpdwCurrentDirectory = len; bSuccess = TRUE; diff --git a/dlls/wininet/utility.c b/dlls/wininet/utility.c index ea7cdf49c45..3810ba7e0b3 100644 --- a/dlls/wininet/utility.c +++ b/dlls/wininet/utility.c @@ -53,15 +53,12 @@ time_t ConvertTimeString(LPCWSTR asctime) if(!asctime || !timelen) return 0; - /* The atoiWs below relie on that tmpChar is \0 padded? */ - strncpyW(tmpChar, asctime, TIME_STRING_LEN); + /* FIXME: the atoiWs below rely on that tmpChar is \0 padded */ + memset( tmpChar, 0, sizeof(tmpChar) ); + lstrcpynW(tmpChar, asctime, TIME_STRING_LEN); /* Assert that the string is the expected length */ - if (tmpChar[TIME_STRING_LEN - 1] != '\0') - { - tmpChar[TIME_STRING_LEN - 1] = '\0'; - FIXME("\n"); - } + if (strlenW(asctime) >= TIME_STRING_LEN) FIXME("\n"); /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure * We assume the time is in this format diff --git a/include/wine/unicode.h b/include/wine/unicode.h index ce3f8d71241..57abd0c4315 100644 --- a/include/wine/unicode.h +++ b/include/wine/unicode.h @@ -204,14 +204,6 @@ static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) return *str1 - *str2; } -static inline WCHAR *strncpyW( WCHAR *str1, const WCHAR *str2, int n ) -{ - WCHAR *ret = str1; - while (n-- > 0) if (!(*str1++ = *str2++)) break; - while (n-- > 0) *str1++ = 0; - return ret; -} - static inline WCHAR *strcatW( WCHAR *dst, const WCHAR *src ) { strcpyW( dst + strlenW(dst), src );