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.
This commit is contained in:
Zebediah Figura 2023-10-14 21:14:20 -05:00 committed by Alexandre Julliard
parent 3ecedb7e14
commit c05973d077

View file

@ -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;