ntdll: Use wcscat() instead of strcatW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-31 11:41:22 +02:00
parent 18411a19b4
commit 80005ee016
9 changed files with 32 additions and 31 deletions

View File

@ -1099,17 +1099,17 @@ static WCHAR *build_assembly_dir(struct assembly_identity* ai)
if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, size ))) return NULL; if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, size ))) return NULL;
wcscpy( ret, arch ); wcscpy( ret, arch );
strcatW( ret, undW ); wcscat( ret, undW );
strcatW( ret, name ); wcscat( ret, name );
strcatW( ret, undW ); wcscat( ret, undW );
strcatW( ret, key ); wcscat( ret, key );
strcatW( ret, undW ); wcscat( ret, undW );
NTDLL_swprintf( ret + strlenW(ret), version_formatW, NTDLL_swprintf( ret + strlenW(ret), version_formatW,
ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); ai->version.major, ai->version.minor, ai->version.build, ai->version.revision );
strcatW( ret, undW ); wcscat( ret, undW );
strcatW( ret, lang ); wcscat( ret, lang );
strcatW( ret, undW ); wcscat( ret, undW );
strcatW( ret, mskeyW ); wcscat( ret, mskeyW );
return ret; return ret;
} }
@ -1118,7 +1118,7 @@ static inline void append_string( WCHAR *buffer, const WCHAR *prefix, const WCHA
WCHAR *p = buffer; WCHAR *p = buffer;
if (!str) return; if (!str) return;
strcatW( buffer, prefix ); wcscat( buffer, prefix );
p += strlenW(p); p += strlenW(p);
*p++ = '"'; *p++ = '"';
wcscpy( p, str ); wcscpy( p, str );
@ -3062,7 +3062,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl,
if (!(status = get_module_filename( module, &name, sizeof(dotManifestW) + 10*sizeof(WCHAR) ))) if (!(status = get_module_filename( module, &name, sizeof(dotManifestW) + 10*sizeof(WCHAR) )))
{ {
if (resid != 1) NTDLL_swprintf( name.Buffer + strlenW(name.Buffer), fmtW, resid ); if (resid != 1) NTDLL_swprintf( name.Buffer + strlenW(name.Buffer), fmtW, resid );
strcatW( name.Buffer, dotManifestW ); wcscat( name.Buffer, dotManifestW );
if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL )) if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL ))
status = STATUS_RESOURCE_DATA_NOT_FOUND; status = STATUS_RESOURCE_DATA_NOT_FOUND;
RtlFreeUnicodeString( &name ); RtlFreeUnicodeString( &name );
@ -3076,7 +3076,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl,
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
wcscpy( buffer, filename ); wcscpy( buffer, filename );
if (resid != 1) NTDLL_swprintf( buffer + strlenW(buffer), fmtW, resid ); if (resid != 1) NTDLL_swprintf( buffer + strlenW(buffer), fmtW, resid );
strcatW( buffer, dotManifestW ); wcscat( buffer, dotManifestW );
RtlInitUnicodeString( &nameW, buffer ); RtlInitUnicodeString( &nameW, buffer );
} }
@ -3700,8 +3700,8 @@ static NTSTATUS build_wndclass_section(ACTIVATION_CONTEXT* actctx, struct strsec
if (entity->u.class.versioned) if (entity->u.class.versioned)
{ {
get_assembly_version(assembly, ptrW); get_assembly_version(assembly, ptrW);
strcatW(ptrW, exclW); wcscat(ptrW, exclW);
strcatW(ptrW, entity->u.class.name); wcscat(ptrW, entity->u.class.name);
} }
else else
{ {

View File

@ -689,7 +689,7 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path )
if (RtlDoesFileExists_U( full_name )) goto done; if (RtlDoesFileExists_U( full_name )) goto done;
if (len < (MAX_PATH - 4) * sizeof(WCHAR) && !strchrW( file_part, '.' )) if (len < (MAX_PATH - 4) * sizeof(WCHAR) && !strchrW( file_part, '.' ))
{ {
strcatW( file_part, exeW ); wcscat( file_part, exeW );
if (RtlDoesFileExists_U( full_name )) goto done; if (RtlDoesFileExists_U( full_name )) goto done;
} }
/* check for builtin path inside system directory */ /* check for builtin path inside system directory */
@ -710,8 +710,8 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path )
len = strlenW( system_dir ); len = strlenW( system_dir );
if (strlenW( name ) >= MAX_PATH - 4 - len) goto failed; if (strlenW( name ) >= MAX_PATH - 4 - len) goto failed;
wcscpy( full_name, system_dir ); wcscpy( full_name, system_dir );
strcatW( full_name, name ); wcscat( full_name, name );
if (!strchrW( name, '.' )) strcatW( full_name, exeW ); if (!strchrW( name, '.' )) wcscat( full_name, exeW );
} }
} }
done: done:

View File

@ -1775,8 +1775,8 @@ static BOOL get_builtin_fullname( UNICODE_STRING *nt_name, const UNICODE_STRING
(strlenW(system_dir) + len + 5) * sizeof(WCHAR) ))) (strlenW(system_dir) + len + 5) * sizeof(WCHAR) )))
return FALSE; return FALSE;
wcscpy( fullname, nt_prefixW ); wcscpy( fullname, nt_prefixW );
strcatW( fullname, system_dir ); wcscat( fullname, system_dir );
strcatW( fullname, filenameW ); wcscat( fullname, filenameW );
done: done:
RtlInitUnicodeString( nt_name, fullname ); RtlInitUnicodeString( nt_name, fullname );
return TRUE; return TRUE;
@ -2860,7 +2860,7 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING *
{ {
/* not found, return file in the system dir to be loaded as builtin */ /* not found, return file in the system dir to be loaded as builtin */
wcscpy( name, system_dir ); wcscpy( name, system_dir );
strcatW( name, search ); wcscat( name, search );
if (!RtlDosPathNameToNtPathName_U( name, nt_name, NULL, NULL )) status = STATUS_NO_MEMORY; if (!RtlDosPathNameToNtPathName_U( name, nt_name, NULL, NULL )) status = STATUS_NO_MEMORY;
} }
else status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH; else status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
@ -2896,7 +2896,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, con
(strlenW(libname)+strlenW(default_ext)+1) * sizeof(WCHAR)))) (strlenW(libname)+strlenW(default_ext)+1) * sizeof(WCHAR))))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
wcscpy( dllname, libname ); wcscpy( dllname, libname );
strcatW( dllname, default_ext ); wcscat( dllname, default_ext );
libname = dllname; libname = dllname;
} }
} }

View File

@ -344,8 +344,8 @@ static HANDLE get_app_key( const WCHAR *app_name )
strlenW(app_name) * sizeof(WCHAR) ); strlenW(app_name) * sizeof(WCHAR) );
if (!str) return 0; if (!str) return 0;
wcscpy( str, AppDefaultsW ); wcscpy( str, AppDefaultsW );
strcatW( str, app_name ); wcscat( str, app_name );
strcatW( str, DllOverridesW ); wcscat( str, DllOverridesW );
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root ); RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
attr.Length = sizeof(attr); attr.Length = sizeof(attr);

View File

@ -679,8 +679,8 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!RtlQueryEnvironmentVariable_U( NULL, &nameW, &valueW )) if (!RtlQueryEnvironmentVariable_U( NULL, &nameW, &valueW ))
{ {
strcatW( valueW.Buffer, dataprefixW ); wcscat( valueW.Buffer, dataprefixW );
strcatW( valueW.Buffer, name ); wcscat( valueW.Buffer, name );
valueW.Length = strlenW(valueW.Buffer) * sizeof(WCHAR); valueW.Length = strlenW(valueW.Buffer) * sizeof(WCHAR);
InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL ); InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL );
status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT );
@ -877,7 +877,7 @@ static LCID unix_locale_to_lcid( const char *unix_name )
wcscpy( win_name, buffer ); wcscpy( win_name, buffer );
if (modifier) if (modifier)
{ {
if (!strcmpW( modifier, latinW )) strcatW( win_name, latnW ); if (!strcmpW( modifier, latinW )) wcscat( win_name, latnW );
else if (!strcmpW( modifier, euroW )) {} /* ignore */ else if (!strcmpW( modifier, euroW )) {} /* ignore */
else return 0; else return 0;
} }

View File

@ -303,6 +303,7 @@ int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... );
#define wcslwr(s) NTDLL__wcslwr(s) #define wcslwr(s) NTDLL__wcslwr(s)
#define wcsupr(s) NTDLL__wcsupr(s) #define wcsupr(s) NTDLL__wcsupr(s)
#define wcscpy(d,s) NTDLL_wcscpy(d,s) #define wcscpy(d,s) NTDLL_wcscpy(d,s)
#define wcscat(d,s) NTDLL_wcscat(d,s)
#define wcstoul(s,e,b) NTDLL_wcstoul(s,e,b) #define wcstoul(s,e,b) NTDLL_wcstoul(s,e,b)
/* convert from straight ASCII to Unicode without depending on the current codepage */ /* convert from straight ASCII to Unicode without depending on the current codepage */

View File

@ -399,7 +399,7 @@ NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(const WCHAR *dos_path, U
{ {
case UNC_PATH: /* \\foo */ case UNC_PATH: /* \\foo */
offset = 2; offset = 2;
strcatW(ntpath->Buffer, UncPfxW); wcscat(ntpath->Buffer, UncPfxW);
break; break;
case DEVICE_PATH: /* \\.\foo */ case DEVICE_PATH: /* \\.\foo */
offset = 4; offset = 4;
@ -409,7 +409,7 @@ NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(const WCHAR *dos_path, U
break; break;
} }
strcatW(ntpath->Buffer, ptr + offset); wcscat(ntpath->Buffer, ptr + offset);
ntpath->Length = strlenW(ntpath->Buffer) * sizeof(WCHAR); ntpath->Length = strlenW(ntpath->Buffer) * sizeof(WCHAR);
if (file_part && *file_part) if (file_part && *file_part)
@ -514,7 +514,7 @@ ULONG WINAPI RtlDosSearchPath_U(LPCWSTR paths, LPCWSTR search, LPCWSTR ext,
/* append '\\' if none is present */ /* append '\\' if none is present */
if (needed > 0 && name[needed - 1] != '\\') name[needed++] = '\\'; if (needed > 0 && name[needed - 1] != '\\') name[needed++] = '\\';
wcscpy(&name[needed], search); wcscpy(&name[needed], search);
if (ext) strcatW(&name[needed], ext); if (ext) wcscat(&name[needed], ext);
if (RtlDoesFileExists_U(name)) if (RtlDoesFileExists_U(name))
{ {
len = RtlGetFullPathName_U(name, buffer_size, buffer, file_part); len = RtlGetFullPathName_U(name, buffer_size, buffer, file_part);

View File

@ -1193,7 +1193,7 @@ static NTSTATUS RTL_KeyHandleCreateObject(ULONG RelativeTo, PCWSTR Path, POBJECT
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
wcscpy(str->Buffer, base); wcscpy(str->Buffer, base);
strcatW(str->Buffer, Path); wcscat(str->Buffer, Path);
str->Length = len - sizeof(WCHAR); str->Length = len - sizeof(WCHAR);
str->MaximumLength = len; str->MaximumLength = len;
InitializeObjectAttributes(regkey, str, OBJ_CASE_INSENSITIVE, NULL, NULL); InitializeObjectAttributes(regkey, str, OBJ_CASE_INSENSITIVE, NULL, NULL);

View File

@ -505,7 +505,7 @@ void version_init(void)
if ((p = strrchrW( appname, '\\' ))) appname = p + 1; if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
wcscpy( appversion, appdefaultsW ); wcscpy( appversion, appdefaultsW );
strcatW( appversion, appname ); wcscat( appversion, appname );
RtlInitUnicodeString( &nameW, appversion ); RtlInitUnicodeString( &nameW, appversion );
attr.RootDirectory = config_key; attr.RootDirectory = config_key;