[FFmpeg-devel] [PATCH 3/6] lavf/tls_apple: fix crash on unexpected PEM types

Rodger Combs rodger.combs at gmail.com
Tue Jun 11 17:16:20 EEST 2019


---
 libavformat/tls_apple.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/tls_apple.c b/libavformat/tls_apple.c
index 2ff6622565..37d63f3b27 100644
--- a/libavformat/tls_apple.c
+++ b/libavformat/tls_apple.c
@@ -165,6 +165,12 @@ static int load_identity(URLContext *h, SecIdentityRef *identity, CFArrayRef *ce
     if ((ret = import_pem(h, c->tls_shared.key_file, &keyArray)) < 0)
         goto end;
 
+    if (CFGetTypeID(CFArrayGetValueAtIndex(*certArray, 0)) != SecCertificateGetTypeID() ||
+        CFGetTypeID(CFArrayGetValueAtIndex(keyArray, 0)) != SecKeyGetTypeID()) {
+        ret = AVERROR_INVALIDDATA;
+        goto end;
+    }
+
     if (!(*identity = SecIdentityCreate(kCFAllocatorDefault,
                                  (SecCertificateRef)CFArrayGetValueAtIndex(*certArray, 0),
                                  (SecKeyRef)CFArrayGetValueAtIndex(keyArray, 0)))) {
-- 
2.21.0



More information about the ffmpeg-devel mailing list