Commit c05973d0 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

advapi32: Fix rewinding the last path segment in SetSecurityInfo().

In particular, handle the case where an object has no name. In theory, this should not happen for regular files, but SetSecurityInfo() is almost certainly not supposed to care about that [i.e. this code probably belongs in the server, at the very least]. However, fixing that will require much more work. While we're at it, rewrite the code to be a little more idiomatic about its intent.
parent 3ecedb7e
......@@ -2969,10 +2969,11 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
return RtlNtStatusToDosError(status);
}
for (name_info->Name.Length-=2; name_info->Name.Length>0; name_info->Name.Length-=2)
if (name_info->Name.Buffer[name_info->Name.Length/2-1]=='\\' ||
name_info->Name.Buffer[name_info->Name.Length/2-1]=='/')
break;
if (name_info->Name.Length && name_info->Name.Buffer[(name_info->Name.Length / 2) - 1] == '\\')
name_info->Name.Length -= 2;
while (name_info->Name.Length && name_info->Name.Buffer[(name_info->Name.Length / 2) - 1] != '\\')
name_info->Name.Length -= 2;
if (name_info->Name.Length)
{
OBJECT_ATTRIBUTES attr;
......
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