mirror of
https://github.com/apple/swift-nio-ssl
synced 2026-11-29 05:24:23 +00:00
Don't pass read-only bytes as mutable to BoringSSL (#129)
Motivation: The BoringSSL version of `BIO_new_mem_buf` takes a const buffer but we pass a mutable one. Modifications: Pass a const buffer. Result: Unsafe instead of Unsafe+Mutable.
This commit is contained in:
1 parent
c8ac6c1f5a
commit
f5dd7a60ff
3 files changed
+4
-4
No files matched your search
@@ -89,7 +89,7 @@ public class NIOSSLCertificate {
|
||||
/// DER format.
|
||||
public convenience init(bytes: [UInt8], format: NIOSSLSerializationFormats) throws {
|
||||
let ref = bytes.withUnsafeBytes { (ptr) -> UnsafeMutablePointer<X509>? in
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(UnsafeMutableRawPointer(mutating: ptr.baseAddress!), CInt(ptr.count))!
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(ptr.baseAddress, CInt(ptr.count))!
|
||||
|
||||
defer {
|
||||
CNIOBoringSSL_BIO_free(bio)
|
||||
@@ -220,7 +220,7 @@ extension NIOSSLCertificate {
|
||||
}
|
||||
|
||||
return try bytes.withUnsafeBytes { (ptr) -> [NIOSSLCertificate] in
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(UnsafeMutableRawPointer(mutating: ptr.baseAddress!), CInt(ptr.count))!
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(ptr.baseAddress, CInt(ptr.count))!
|
||||
defer {
|
||||
CNIOBoringSSL_BIO_free(bio)
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public struct NIOSSLPKCS12Bundle {
|
||||
guard boringSSLIsInitialized else { fatalError("Failed to initialize BoringSSL") }
|
||||
|
||||
let p12 = buffer.withUnsafeBytes { pointer -> OpaquePointer? in
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(UnsafeMutableRawPointer(mutating: pointer.baseAddress), CInt(pointer.count))!
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(pointer.baseAddress, CInt(pointer.count))!
|
||||
defer {
|
||||
CNIOBoringSSL_BIO_free(bio)
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class NIOSSLPrivateKey {
|
||||
/// A delegating initializer for `init(buffer:format:passphraseCallback)` and `init(buffer:format:)`.
|
||||
private convenience init(bytes: [UInt8], format: NIOSSLSerializationFormats, callbackManager: CallbackManagerProtocol?) throws {
|
||||
let ref = bytes.withUnsafeBytes { (ptr) -> UnsafeMutablePointer<EVP_PKEY>? in
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(UnsafeMutableRawPointer(mutating: ptr.baseAddress!), CInt(ptr.count))!
|
||||
let bio = CNIOBoringSSL_BIO_new_mem_buf(ptr.baseAddress!, CInt(ptr.count))!
|
||||
defer {
|
||||
CNIOBoringSSL_BIO_free(bio)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user