From 3150e61e005750f9aa874f4c8fce297414d254a9 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sun, 12 Jul 2026 19:15:31 +0200 Subject: [PATCH] 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. --- src/libpttls/pt_tls_server.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libpttls/pt_tls_server.c b/src/libpttls/pt_tls_server.c index d33a36212..b9baead54 100644 --- a/src/libpttls/pt_tls_server.c +++ b/src/libpttls/pt_tls_server.c @@ -406,7 +406,7 @@ static status_t assess(private_pt_tls_server_t *this, tls_t *tnccs) { size_t msglen; size_t buflen = PT_TLS_MAX_MESSAGE_LEN; - char buf[buflen]; + char *buf; bio_reader_t *reader; uint32_t vendor, type, identifier; chunk_t data; @@ -451,6 +451,11 @@ static status_t assess(private_pt_tls_server_t *this, tls_t *tnccs) } reader->destroy(reader); + buf = malloc(buflen); + if (!buf) + { + return FAILED; + } status = tnccs->build(tnccs, buf, &buflen, &msglen); 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, this->identifier++, data)) { + free(buf); return FAILED; } } + free(buf); return status; }