Treat OOM in GCC certificates
This patch treats OOM cases and do a trivial cleanup
This commit is contained in:
parent
50f1f0df6f
commit
e79c6b7d68
@ -717,13 +717,7 @@ void key_free(rdpRsaKey* key)
|
||||
|
||||
rdpCertificate* certificate_new()
|
||||
{
|
||||
rdpCertificate* certificate;
|
||||
|
||||
certificate = (rdpCertificate*) calloc(1, sizeof(rdpCertificate));
|
||||
if (!certificate)
|
||||
return NULL;
|
||||
|
||||
return certificate;
|
||||
return (rdpCertificate*) calloc(1, sizeof(rdpCertificate));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -982,37 +982,31 @@ BOOL gcc_read_server_security_data(wStream* s, rdpMcs* mcs)
|
||||
if (Stream_GetRemainingLength(s) < settings->ServerRandomLength + settings->ServerCertificateLength)
|
||||
return FALSE;
|
||||
|
||||
if (settings->ServerRandomLength > 0)
|
||||
{
|
||||
/* serverRandom */
|
||||
settings->ServerRandom = (BYTE*) malloc(settings->ServerRandomLength);
|
||||
Stream_Read(s, settings->ServerRandom, settings->ServerRandomLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((settings->ServerRandomLength <= 0) || (settings->ServerCertificateLength <= 0))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (settings->ServerCertificateLength > 0)
|
||||
{
|
||||
/* serverCertificate */
|
||||
settings->ServerCertificate = (BYTE*) malloc(settings->ServerCertificateLength);
|
||||
Stream_Read(s, settings->ServerCertificate, settings->ServerCertificateLength);
|
||||
|
||||
certificate_free(settings->RdpServerCertificate);
|
||||
settings->RdpServerCertificate = certificate_new();
|
||||
data = settings->ServerCertificate;
|
||||
length = settings->ServerCertificateLength;
|
||||
|
||||
if (certificate_read_server_certificate(settings->RdpServerCertificate, data, length) < 1)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* serverRandom */
|
||||
settings->ServerRandom = (BYTE*) malloc(settings->ServerRandomLength);
|
||||
if (!settings->ServerRandom)
|
||||
return FALSE;
|
||||
}
|
||||
Stream_Read(s, settings->ServerRandom, settings->ServerRandomLength);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* serverCertificate */
|
||||
settings->ServerCertificate = (BYTE*) malloc(settings->ServerCertificateLength);
|
||||
if (!settings->ServerCertificate)
|
||||
return FALSE;
|
||||
Stream_Read(s, settings->ServerCertificate, settings->ServerCertificateLength);
|
||||
|
||||
certificate_free(settings->RdpServerCertificate);
|
||||
settings->RdpServerCertificate = certificate_new();
|
||||
if (!settings->RdpServerCertificate)
|
||||
return FALSE;
|
||||
|
||||
data = settings->ServerCertificate;
|
||||
length = settings->ServerCertificateLength;
|
||||
|
||||
return certificate_read_server_certificate(settings->RdpServerCertificate, data, length);
|
||||
}
|
||||
|
||||
static const BYTE initial_signature[] =
|
||||
|
Loading…
Reference in New Issue
Block a user