pt-tls-server: Don't store PT-TLS message on stack
The size of that buffer was ~2 MB, which is not ideal for systems with restricted stack sizes.
This commit is contained in:
@@ -406,7 +406,7 @@ static status_t assess(private_pt_tls_server_t *this, tls_t *tnccs)
|
|||||||
{
|
{
|
||||||
size_t msglen;
|
size_t msglen;
|
||||||
size_t buflen = PT_TLS_MAX_MESSAGE_LEN;
|
size_t buflen = PT_TLS_MAX_MESSAGE_LEN;
|
||||||
char buf[buflen];
|
char *buf;
|
||||||
bio_reader_t *reader;
|
bio_reader_t *reader;
|
||||||
uint32_t vendor, type, identifier;
|
uint32_t vendor, type, identifier;
|
||||||
chunk_t data;
|
chunk_t data;
|
||||||
@@ -451,6 +451,11 @@ static status_t assess(private_pt_tls_server_t *this, tls_t *tnccs)
|
|||||||
}
|
}
|
||||||
reader->destroy(reader);
|
reader->destroy(reader);
|
||||||
|
|
||||||
|
buf = malloc(buflen);
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
status = tnccs->build(tnccs, buf, &buflen, &msglen);
|
status = tnccs->build(tnccs, buf, &buflen, &msglen);
|
||||||
if (status == ALREADY_DONE)
|
if (status == ALREADY_DONE)
|
||||||
{
|
{
|
||||||
@@ -458,9 +463,11 @@ static status_t assess(private_pt_tls_server_t *this, tls_t *tnccs)
|
|||||||
if (!pt_tls_write(this->tls, PT_TLS_PB_TNC_BATCH,
|
if (!pt_tls_write(this->tls, PT_TLS_PB_TNC_BATCH,
|
||||||
this->identifier++, data))
|
this->identifier++, data))
|
||||||
{
|
{
|
||||||
|
free(buf);
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(buf);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user