Description: fix rdp client read server proprietary certificate DoS
Origin: backport, https://github.com/FreeRDP/FreeRDP/commit/03ab68318966c3a22935a02838daaea7b7fbe96c
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=869880

Index: freerdp-1.0.2/libfreerdp-core/certificate.c
===================================================================
--- freerdp-1.0.2.orig/libfreerdp-core/certificate.c	2013-01-02 16:46:59.000000000 -0500
+++ freerdp-1.0.2/libfreerdp-core/certificate.c	2017-08-03 08:29:34.035389657 -0400
@@ -254,6 +254,9 @@ static boolean certificate_process_serve
 	uint32 datalen;
 	uint32 modlen;
 
+ 	if (stream_get_left(s) < 20)
+ 		return false;
+
 	stream_read(s, magic, 4);
 	if (memcmp(magic, "RSA1", 4) != 0)
 	{
@@ -265,6 +268,10 @@ static boolean certificate_process_serve
 	stream_read_uint32(s, bitlen);
 	stream_read_uint32(s, datalen);
 	stream_read(s, certificate->cert_info.exponent, 4);
+
+	if ((keylen <= 8) || (stream_get_left(s) < keylen))
+		return false;
+
 	modlen = keylen - 8;
 	freerdp_blob_alloc(&(certificate->cert_info.modulus), modlen);
 	stream_read(s, certificate->cert_info.modulus.data, modlen);
