Skip to content

Commit a4328a1

Browse files
committed
Fix inconsistency in p/invoke arguments introduced when switching some to be blittable
1 parent 6d5f59b commit a4328a1

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.NetSecurityNative.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ internal static partial class Interop
1111
{
1212
internal static partial class NetSecurityNative
1313
{
14-
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseGssBuffer")]
15-
internal static extern void ReleaseGssBuffer(
14+
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseGssBuffer")]
15+
internal static partial void ReleaseGssBuffer(
1616
IntPtr bufferPtr,
1717
ulong length);
1818

@@ -42,10 +42,10 @@ internal static partial Status ImportPrincipalName(
4242
int inputNameByteCount,
4343
out SafeGssNameHandle outputName);
4444

45-
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseName")]
46-
internal static unsafe extern Status ReleaseName(
47-
Status* minorStatus,
48-
IntPtr* inputName);
45+
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseName")]
46+
internal static partial Status ReleaseName(
47+
out Status minorStatus,
48+
ref IntPtr inputName);
4949

5050
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcquireAcceptorCred")]
5151
internal static partial Status AcquireAcceptorCred(
@@ -67,10 +67,10 @@ internal static partial Status InitiateCredWithPassword(
6767
int passwordLen,
6868
out SafeGssCredHandle outputCredHandle);
6969

70-
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseCred")]
71-
internal static unsafe extern Status ReleaseCred(
72-
Status* minorStatus,
73-
IntPtr* credHandle);
70+
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseCred")]
71+
internal static partial Status ReleaseCred(
72+
out Status minorStatus,
73+
ref IntPtr credHandle);
7474

7575
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContext")]
7676
internal static partial Status InitSecContext(
@@ -113,10 +113,10 @@ internal static partial Status AcceptSecContext(
113113
out uint retFlags,
114114
out bool isNtlmUsed);
115115

116-
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")]
117-
internal static unsafe extern Status DeleteSecContext(
118-
Status* minorStatus,
119-
IntPtr* contextHandle);
116+
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")]
117+
internal static partial Status DeleteSecContext(
118+
out Status minorStatus,
119+
ref IntPtr contextHandle);
120120

121121
[GeneratedDllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_GetUser")]
122122
internal static partial Status GetUser(

src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,12 @@ public override bool IsInvalid
5252
get { return handle == IntPtr.Zero; }
5353
}
5454

55-
protected override unsafe bool ReleaseHandle()
55+
protected override bool ReleaseHandle()
5656
{
5757
Interop.NetSecurityNative.Status minorStatus;
58-
fixed (IntPtr* handleRef = &handle)
59-
{
60-
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(&minorStatus, handleRef);
61-
SetHandle(IntPtr.Zero);
62-
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
63-
}
58+
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseName(out minorStatus, ref handle);
59+
SetHandle(IntPtr.Zero);
60+
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
6461
}
6562

6663
public SafeGssNameHandle()
@@ -144,15 +141,12 @@ public override bool IsInvalid
144141
get { return handle == IntPtr.Zero; }
145142
}
146143

147-
protected override unsafe bool ReleaseHandle()
144+
protected override bool ReleaseHandle()
148145
{
149146
Interop.NetSecurityNative.Status minorStatus;
150-
fixed (IntPtr* handlePtr = &handle)
151-
{
152-
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(&minorStatus, handlePtr);
153-
SetHandle(IntPtr.Zero);
154-
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
155-
}
147+
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.ReleaseCred(out minorStatus, ref handle);
148+
SetHandle(IntPtr.Zero);
149+
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
156150
}
157151

158152
private static bool InitIsNtlmInstalled()
@@ -176,12 +170,9 @@ public override bool IsInvalid
176170
protected override unsafe bool ReleaseHandle()
177171
{
178172
Interop.NetSecurityNative.Status minorStatus;
179-
fixed (IntPtr* handlePtr = &handle)
180-
{
181-
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(&minorStatus, handlePtr);
182-
SetHandle(IntPtr.Zero);
183-
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
184-
}
173+
Interop.NetSecurityNative.Status status = Interop.NetSecurityNative.DeleteSecContext(out minorStatus, ref handle);
174+
SetHandle(IntPtr.Zero);
175+
return status == Interop.NetSecurityNative.Status.GSS_S_COMPLETE;
185176
}
186177
}
187178
}

0 commit comments

Comments
 (0)