diff mbox

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

Message ID 20190611141623.59440-3-rodger.combs@gmail.com
State Withdrawn, archived
Headers show

Commit Message

Rodger Combs June 11, 2019, 2:16 p.m. UTC
---
 libavformat/tls_apple.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

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)))) {