Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fab4772

Browse files
committed
Merge pull request #5642 from CIPop/snsasserts1
Fixing assert conditions for System.Net.Security.
2 parents 47d1490 + 1baa844 commit fab4772

24 files changed

+94
-19
lines changed

src/Common/src/Interop/Windows/SChannel/SslConnectionInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ internal unsafe SslConnectionInfo(byte[] nativeBuffer)
4242
{
4343
GlobalLog.Assert("SslConnectionInfo::.ctor", "Negative size.");
4444
}
45+
4546
Debug.Fail("SslConnectionInfo::.ctor", "Negative size.");
4647
throw;
4748
}

src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ public unsafe int DecryptMessage(SafeDeleteContext context, Interop.SspiCli.Secu
105105
context.DangerousRelease();
106106
}
107107

108-
109108
if (status == 0 && qop == Interop.SspiCli.SECQOP_WRAP_NO_ENCRYPT)
110109
{
111110
if (GlobalLog.IsEnabled)
112111
{
113112
GlobalLog.Assert("SspiCli.DecryptMessage", "Expected qop = 0, returned value = " + qop.ToString("x", CultureInfo.InvariantCulture));
114113
}
114+
115115
Debug.Fail("SspiCli.DecryptMessage", "Expected qop = 0, returned value = " + qop.ToString("x", CultureInfo.InvariantCulture));
116116
throw new InvalidOperationException(SR.net_auth_message_not_encrypted);
117117
}

src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S
413413
{
414414
GlobalLog.Assert("SSPIWrapper::EncryptDecryptHelper", "Unknown OP: " + op);
415415
}
416+
416417
Debug.Fail("SSPIWrapper::EncryptDecryptHelper", "Unknown OP: " + op);
417418
throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
418419
}
@@ -458,6 +459,7 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S
458459
{
459460
GlobalLog.Assert("SSPIWrapper::EncryptDecryptHelper", "Output buffer out of range.");
460461
}
462+
461463
Debug.Fail("SSPIWrapper::EncryptDecryptHelper", "Output buffer out of range.");
462464
iBuffer.size = 0;
463465
iBuffer.offset = 0;
@@ -473,14 +475,17 @@ private unsafe static int EncryptDecryptHelper(OP op, SSPIInterface secModule, S
473475
{
474476
GlobalLog.AssertFormat("SSPIWrapper::EncryptDecryptHelper|'offset' out of range. [{0}]", iBuffer.offset);
475477
}
478+
476479
Debug.Fail("SSPIWrapper::EncryptDecryptHelper|'offset' out of range. [" + iBuffer.offset + "]");
477480
}
481+
478482
if (iBuffer.size < 0 || iBuffer.size > (iBuffer.token == null ? 0 : iBuffer.token.Length - iBuffer.offset))
479483
{
480484
if (GlobalLog.IsEnabled)
481485
{
482486
GlobalLog.AssertFormat("SSPIWrapper::EncryptDecryptHelper|'size' out of range. [{0}]", iBuffer.size);
483487
}
488+
484489
Debug.Fail("SSPIWrapper::EncryptDecryptHelper|'size' out of range. [" + iBuffer.size + "]");
485490
}
486491
}

src/Common/src/Interop/Windows/sspicli/SecSizes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ internal unsafe SecSizes(byte[] memory)
3434
{
3535
GlobalLog.Assert("SecSizes::.ctor", "Negative size.");
3636
}
37+
3738
Debug.Fail("SecSizes::.ctor", "Negative size.");
3839
throw;
3940
}

src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ internal unsafe static int InitializeSecurityContext(
549549
{
550550
GlobalLog.Assert("SafeDeleteContext::InitializeSecurityContext()|outSecBuffer != null");
551551
}
552+
552553
Debug.Fail("SafeDeleteContext::InitializeSecurityContext()|outSecBuffer != null");
553554
}
554555
if (inSecBuffer != null && inSecBuffers != null)
@@ -557,6 +558,7 @@ internal unsafe static int InitializeSecurityContext(
557558
{
558559
GlobalLog.Assert("SafeDeleteContext::InitializeSecurityContext()|inSecBuffer == null || inSecBuffers == null");
559560
}
561+
560562
Debug.Fail("SafeDeleteContext::InitializeSecurityContext()|inSecBuffer == null || inSecBuffers == null");
561563
}
562564

@@ -859,6 +861,7 @@ internal unsafe static int AcceptSecurityContext(
859861
{
860862
GlobalLog.Assert("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null");
861863
}
864+
862865
Debug.Fail("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null");
863866
}
864867
if (inSecBuffer != null && inSecBuffers != null)
@@ -867,6 +870,7 @@ internal unsafe static int AcceptSecurityContext(
867870
{
868871
GlobalLog.Assert("SafeDeleteContext::AcceptSecurityContext()|inSecBuffer == null || inSecBuffers == null");
869872
}
873+
870874
Debug.Fail("SafeDeleteContext::AcceptSecurityContext()|outSecBuffer != null");
871875
}
872876

@@ -1142,6 +1146,7 @@ internal unsafe static int CompleteAuthToken(
11421146
{
11431147
GlobalLog.Assert("SafeDeleteContext::CompleteAuthToken()|inSecBuffers == null");
11441148
}
1149+
11451150
Debug.Fail("SafeDeleteContext::CompleteAuthToken()|inSecBuffers == null");
11461151
}
11471152

src/Common/src/Interop/Windows/sspicli/StreamSizes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal unsafe StreamSizes(byte[] memory)
3636
{
3737
GlobalLog.Assert("StreamSizes::.ctor", "Negative size.");
3838
}
39+
3940
Debug.Fail("StreamSizes::.ctor", "Negative size.");
4041
throw;
4142
}

src/Common/src/System/Net/ContextAwareResult.Windows.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal WindowsIdentity Identity
3131
{
3232
GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Called on completed result.", LoggingHash.HashString(this));
3333
}
34+
3435
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Called on completed result.");
3536
}
3637

@@ -49,6 +50,7 @@ internal WindowsIdentity Identity
4950
{
5051
GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|No identity captured - specify captureIdentity.", LoggingHash.HashString(this));
5152
}
53+
5254
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |No identity captured - specify captureIdentity.");
5355
}
5456

@@ -62,8 +64,10 @@ internal WindowsIdentity Identity
6264
{
6365
GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling Identity (unless it's only called after FinishPostingAsyncOp).", LoggingHash.HashString(this));
6466
}
67+
6568
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling Identity (unless it's only called after FinishPostingAsyncOp).");
6669
}
70+
6771
lock (_lock) { }
6872
}
6973

@@ -75,6 +79,7 @@ internal WindowsIdentity Identity
7579
{
7680
GlobalLog.AssertFormat("ContextAwareResult#{0}::Identity|Result became completed during call.", LoggingHash.HashString(this));
7781
}
82+
7883
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::Identity |Result became completed during call.");
7984
}
8085

src/Common/src/System/Net/ContextAwareResult.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ internal ExecutionContext ContextCopy
138138
{
139139
GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Called on completed result.", LoggingHash.HashString(this));
140140
}
141+
141142
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |Called on completed result.");
142143
}
143144

@@ -157,6 +158,7 @@ internal ExecutionContext ContextCopy
157158
{
158159
GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|No context captured - specify a callback or forceCaptureContext.", LoggingHash.HashString(this));
159160
}
161+
160162
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |No context captured - specify a callback or forceCaptureContext.");
161163
}
162164

@@ -170,6 +172,7 @@ internal ExecutionContext ContextCopy
170172
{
171173
GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling ContextCopy (unless it's only called after FinishPostingAsyncOp).", LoggingHash.HashString(this));
172174
}
175+
173176
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) +"::ContextCopy |Must lock (StartPostingAsyncOp()) { ... FinishPostingAsyncOp(); } when calling ContextCopy (unless it's only called after FinishPostingAsyncOp).");
174177
}
175178
lock (_lock) { }
@@ -183,6 +186,7 @@ internal ExecutionContext ContextCopy
183186
{
184187
GlobalLog.AssertFormat("ContextAwareResult#{0}::ContextCopy|Result became completed during call.", LoggingHash.HashString(this));
185188
}
189+
186190
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::ContextCopy |Result became completed during call.");
187191
}
188192

@@ -221,6 +225,7 @@ internal object StartPostingAsyncOp(bool lockCapture)
221225
{
222226
GlobalLog.AssertFormat("ContextAwareResult#{0}::StartPostingAsyncOp|Called on completed result.", LoggingHash.HashString(this));
223227
}
228+
224229
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::StartPostingAsyncOp |Called on completed result.");
225230
}
226231

@@ -318,6 +323,7 @@ private bool CaptureOrComplete(ref ExecutionContext cachedContext, bool returnCo
318323
{
319324
GlobalLog.AssertFormat("ContextAwareResult#{0}::CaptureOrComplete|Called without calling StartPostingAsyncOp.", LoggingHash.HashString(this));
320325
}
326+
321327
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::CaptureOrComplete |Called without calling StartPostingAsyncOp.");
322328
}
323329

@@ -384,6 +390,7 @@ private bool CaptureOrComplete(ref ExecutionContext cachedContext, bool returnCo
384390
{
385391
GlobalLog.AssertFormat("ContextAwareResult#{0}::CaptureOrComplete|Didn't capture context, but didn't complete synchronously!", LoggingHash.HashString(this));
386392
}
393+
387394
Debug.Fail("ContextAwareResult#" + LoggingHash.HashString(this) + "::CaptureOrComplete |Didn't capture context, but didn't complete synchronously!");
388395
}
389396
}

src/Common/src/System/Net/InternalException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ internal InternalException()
1313
{
1414
GlobalLog.Assert("InternalException thrown.");
1515
}
16+
1617
Debug.Fail("InternalException thrown.");
1718
}
1819
}

src/Common/src/System/Net/LazyAsyncResult.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ internal LazyAsyncResult(object myObject, object myState, AsyncCallback myCallBa
7979
{
8080
GlobalLog.AssertFormat("LazyAsyncResult#{0}::.ctor()|Result can't be set to DBNull - it's a special internal value.", LoggingHash.HashString(this));
8181
}
82+
8283
Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::.ctor()|Result can't be set to DBNull - it's a special internal value.");
8384
}
8485

@@ -335,14 +336,17 @@ internal object Result
335336
{
336337
GlobalLog.AssertFormat("LazyAsyncResult#{0}::set_Result()|Result can't be set to DBNull - it's a special internal value.", LoggingHash.HashString(this));
337338
}
339+
338340
Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::set_Result()|Result can't be set to DBNull - it's a special internal value.");
339341
}
342+
340343
if (InternalPeekCompleted)
341344
{
342345
if (GlobalLog.IsEnabled)
343346
{
344347
GlobalLog.AssertFormat("LazyAsyncResult#{0}::set_Result()|Called on completed result.", LoggingHash.HashString(this));
345348
}
349+
346350
Debug.Fail("LazyAsyncResult#" + LoggingHash.HashString(this) + "::set_Result()|Called on completed result.");
347351
}
348352
_result = value;

0 commit comments

Comments
 (0)