Commit 2f7cc584 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Use RtlCompareUnicodeStrings() instead of strncmpiW().

parent 4d93bafe
......@@ -2102,7 +2102,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
{
ret = ntdll_umbstowcs( kde[1].d_name, strlen(kde[1].d_name),
buffer, MAX_DIR_ENTRY_LEN );
if (ret == length && !strncmpiW( buffer, name, length))
if (ret == length && !RtlCompareUnicodeStrings( buffer, ret, name, ret, TRUE ))
{
strcpy( unix_name + pos, kde[1].d_name );
RtlLeaveCriticalSection( &dir_section );
......@@ -2112,7 +2112,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
}
ret = ntdll_umbstowcs( kde[0].d_name, strlen(kde[0].d_name),
buffer, MAX_DIR_ENTRY_LEN );
if (ret == length && !strncmpiW( buffer, name, length))
if (ret == length && !RtlCompareUnicodeStrings( buffer, ret, name, ret, TRUE ))
{
strcpy( unix_name + pos,
kde[1].d_name[0] ? kde[1].d_name : kde[0].d_name );
......@@ -2146,7 +2146,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
while ((de = readdir( dir )))
{
ret = ntdll_umbstowcs( de->d_name, strlen(de->d_name), buffer, MAX_DIR_ENTRY_LEN );
if (ret == length && !strncmpiW( buffer, name, length ))
if (ret == length && !RtlCompareUnicodeStrings( buffer, ret, name, ret, TRUE ))
{
strcpy( unix_name + pos, de->d_name );
closedir( dir );
......
......@@ -903,16 +903,20 @@ NTSTATUS WINAPI RtlDestroyEnvironment(PWSTR env)
static LPCWSTR ENV_FindVariable(PCWSTR var, PCWSTR name, unsigned namelen)
{
for (; *var; var += strlenW(var) + 1)
while (*var)
{
/* match var names, but avoid setting a var with a name including a '='
* (a starting '=' is valid though)
*/
if (strncmpiW(var, name, namelen) == 0 && var[namelen] == '=' &&
strchrW(var + 1, '=') == var + namelen)
unsigned int len = strlenW( var );
if (len > namelen &&
var[namelen] == '=' &&
!RtlCompareUnicodeStrings( var, namelen, name, namelen, TRUE ) &&
strchrW(var + 1, '=') == var + namelen)
{
return var + namelen + 1;
}
var += len + 1;
}
return NULL;
}
......@@ -987,7 +991,7 @@ void WINAPI RtlSetCurrentEnvironment(PWSTR new_env, PWSTR* old_env)
NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
PUNICODE_STRING value)
{
INT len, old_size;
INT varlen, len, old_size;
LPWSTR p, env;
NTSTATUS nts = STATUS_VARIABLE_NOT_FOUND;
......@@ -1011,9 +1015,11 @@ NTSTATUS WINAPI RtlSetEnvironmentVariable(PWSTR* penv, PUNICODE_STRING name,
old_size = get_env_length( env );
/* Find a place to insert the string */
for (p = env; *p; p += strlenW(p) + 1)
for (p = env; *p; p += varlen + 1)
{
if (!strncmpiW(name->Buffer, p, len) && (p[len] == '=')) break;
varlen = strlenW(p);
if (varlen > len && p[len] == '=' &&
!RtlCompareUnicodeStrings( name->Buffer, len, p, len, TRUE )) break;
}
if (!value && !*p) goto done; /* Value to remove doesn't exist */
......
......@@ -2768,10 +2768,12 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname )
if ((p = strrchrW( info->lpAssemblyManifestPath, '\\' )))
{
DWORD dirlen = info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
DWORD len, dirlen = info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
p++;
if (!dirlen || strncmpiW( p, info->lpAssemblyDirectoryName, dirlen ) || wcsicmp( p + dirlen, dotManifestW ))
len = strlenW( p );
if (!dirlen || len <= dirlen ||
RtlCompareUnicodeStrings( p, dirlen, info->lpAssemblyDirectoryName, dirlen, TRUE ) ||
wcsicmp( p + dirlen, dotManifestW ))
{
/* manifest name does not match directory name, so it's not a global
* windows/winsxs manifest; use the manifest directory name instead */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment