rtmpdh: Check the output buffer size in the openssl version of dh_compute_key
authorMartin Storsjö <martin@martin.st>
Thu, 28 May 2015 07:08:27 +0000 (10:08 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 29 May 2015 06:42:30 +0000 (09:42 +0300)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtmpdh.c

index bd9813d..80cced9 100644 (file)
@@ -189,7 +189,14 @@ void ff_dh_free(FF_DH *dh)
 
 #define dh_new()                                DH_new()
 #define dh_generate_key(dh)                     DH_generate_key(dh)
-#define dh_compute_key(dh, pub, len, secret)    DH_compute_key(secret, pub, dh)
+
+static int dh_compute_key(FF_DH *dh, FFBigNum pub_key_bn,
+                          uint32_t secret_key_len, uint8_t *secret_key)
+{
+    if (secret_key_len < DH_size(dh))
+        return AVERROR(EINVAL);
+    return DH_compute_key(secret_key, pub_key_bn, dh);
+}
 
 void ff_dh_free(FF_DH *dh)
 {