Menu

#302 Win32Helper Fails on comparing two null sids

FlexWiki
open
build (4)
5
2009-08-11
2009-08-11
No

Not sure if this is the right project to log this bug, but here we go. I've used the Microsoft.Win32.Security library found in flexwiki for setting permissions on shares. Doing this it fails in the UnsafeSetNamedSecurityInfo method in the Win32helper.cs file with a null pointer exception.

The error is due to a operator overload in the Sid class (Sid.cs). The overload operator calls a method called UnsafeEqualsSids which starts like this:

private static unsafe bool UnsafeEqualsSids(Sid s1, Sid s2)
{
if (object.ReferenceEquals(s1, null) || object.ReferenceEquals(s2, null))
{
return false;
}

This method fails if both sids are null. The following code inserts another tests which checks if both sids are null and then return true instead of false.

private static unsafe bool UnsafeEqualsSids(Sid s1, Sid s2)
{
if (object.ReferenceEquals(s1, null) && object.ReferenceEquals(s2, null))
{
return true;
}
if (object.ReferenceEquals(s1, null) || object.ReferenceEquals(s2, null))
{
return false;
}

Discussion


Log in to post a comment.