File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
src/libraries/Common/src/Interop/Unix
System.Security.Cryptography.Native Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Runtime . InteropServices ;
6
+ using System . Runtime . InteropServices . Marshalling ;
6
7
7
8
internal static partial class Interop
8
9
{
@@ -179,7 +180,7 @@ internal static unsafe string StrError(int platformErrno)
179
180
message = buffer ;
180
181
}
181
182
182
- return Marshal . PtrToStringUTF8 ( ( IntPtr ) message ) ! ;
183
+ return Utf8StringMarshaller . ConvertToManaged ( message ) ! ;
183
184
}
184
185
185
186
#if SERIAL_PORTS
Original file line number Diff line number Diff line change 4
4
using System ;
5
5
using System . Diagnostics ;
6
6
using System . Runtime . InteropServices ;
7
+ using System . Runtime . InteropServices . Marshalling ;
7
8
using System . Security . Cryptography ;
8
9
9
10
using Microsoft . Win32 . SafeHandles ;
@@ -67,7 +68,7 @@ internal static unsafe string GetOidValue(IntPtr asn1ObjectPtr)
67
68
68
69
if ( bytesNeeded < StackCapacity )
69
70
{
70
- return Marshal . PtrToStringUTF8 ( ( IntPtr ) bufStack , bytesNeeded ) ;
71
+ return Utf8StringMarshaller . ConvertToManaged ( bufStack , bytesNeeded ) ;
71
72
}
72
73
73
74
// bytesNeeded does not count the \0 which will be written on the end (based on OpenSSL 1.0.1f),
@@ -93,7 +94,7 @@ internal static unsafe string GetOidValue(IntPtr asn1ObjectPtr)
93
94
throw new CryptographicException ( ) ;
94
95
}
95
96
96
- return Marshal . PtrToStringUTF8 ( ( IntPtr ) buf , bytesNeeded ) ;
97
+ return Utf8StringMarshaller . ConvertToManaged ( buf , bytesNeeded ) ;
97
98
}
98
99
}
99
100
}
Original file line number Diff line number Diff line change 5
5
using System . Diagnostics ;
6
6
using System . Globalization ;
7
7
using System . Runtime . InteropServices ;
8
+ using System . Runtime . InteropServices . Marshalling ;
8
9
using System . Security . Cryptography ;
9
10
using System . Security . Cryptography . X509Certificates ;
10
11
using Microsoft . Win32 . SafeHandles ;
@@ -71,13 +72,13 @@ internal static int BioTell(SafeBioHandle bio)
71
72
byte usedDefault ;
72
73
IntPtr ptr = GetX509RootStorePath_private ( & usedDefault ) ;
73
74
defaultPath = ( usedDefault != 0 ) ;
74
- return Marshal . PtrToStringUTF8 ( ptr ) ;
75
+ return Utf8StringMarshaller . ConvertToManaged ( ptr ) ;
75
76
}
76
77
77
78
internal static unsafe string ? GetX509RootStoreFile ( )
78
79
{
79
80
byte unused ;
80
- return Marshal . PtrToStringUTF8 ( GetX509RootStoreFile_private ( & unused ) ) ;
81
+ return Utf8StringMarshaller . ConvertToManaged ( GetX509RootStoreFile_private ( & unused ) ) ;
81
82
}
82
83
83
84
[ LibraryImport ( Libraries . CryptoNative , EntryPoint = "CryptoNative_GetX509RootStorePath" ) ]
Original file line number Diff line number Diff line change 12
12
using System . Net ;
13
13
using System . Net . Security ;
14
14
using System . Runtime . InteropServices ;
15
+ using System . Runtime . InteropServices . Marshalling ;
15
16
using System . Security . Authentication ;
16
17
using System . Security . Authentication . ExtendedProtection ;
17
18
using System . Security . Cryptography ;
@@ -1077,7 +1078,7 @@ internal static SslException CreateSslException(string message)
1077
1078
// Capture last error to be consistent with CreateOpenSslCryptographicException
1078
1079
ulong errorVal = Crypto . ErrPeekLastError ( ) ;
1079
1080
Crypto . ErrClearError ( ) ;
1080
- string msg = SR . Format ( message , Marshal . PtrToStringUTF8 ( Crypto . ErrReasonErrorString ( errorVal ) ) ) ;
1081
+ string msg = SR . Format ( message , Utf8StringMarshaller . ConvertToManaged ( Crypto . ErrReasonErrorString ( errorVal ) ) ) ;
1081
1082
return new SslException ( msg , ( int ) errorVal ) ;
1082
1083
}
1083
1084
You can’t perform that action at this time.
0 commit comments