[Mono.Security]: Fix TLS Alert level." This breaks the System test suite.
authorMartin Baulig <martin.baulig@xamarin.com>
Thu, 15 Jan 2015 16:04:21 +0000 (17:04 +0100)
committerMartin Baulig <martin.baulig@xamarin.com>
Thu, 15 Jan 2015 16:53:57 +0000 (17:53 +0100)
Prevent further abuse (calling it before the fields have been assigned to)
by making the helper function static.

mcs/class/Mono.Security/Mono.Security.Protocol.Tls/Alert.cs

index b40292c2b94e0c078b0f47d926cb3048d3455ae9..62ac7b9f2931bbab64f5967f9878b54ab01f7d2b 100644 (file)
@@ -124,8 +124,8 @@ namespace Mono.Security.Protocol.Tls
 
                public Alert(AlertDescription description)
                {
-                       this.inferAlertLevel();
                        this.description = description;
+                       this.level = inferAlertLevel(description);
                }
 
                public Alert(
@@ -140,15 +140,14 @@ namespace Mono.Security.Protocol.Tls
 
                #region Private Methods
 
-               private void inferAlertLevel()
+               private static AlertLevel inferAlertLevel(AlertDescription description)
                {
                        switch (description)
                        {
                                case AlertDescription.CloseNotify:
                                case AlertDescription.NoRenegotiation:
                                case AlertDescription.UserCancelled:
-                                       this.level = AlertLevel.Warning;
-                                       break;
+                                       return AlertLevel.Warning;
 
                                case AlertDescription.AccessDenied:
                                case AlertDescription.BadCertificate:
@@ -171,8 +170,7 @@ namespace Mono.Security.Protocol.Tls
                                case AlertDescription.UnknownCA:
                                case AlertDescription.UnsupportedCertificate:
                                default:
-                                       this.level = AlertLevel.Fatal;
-                                       break;
+                                       return AlertLevel.Fatal;
                        }
                }