ssl_client2: Add buffer overflow check

Add buffer overflow check to build_http_request().

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2024-01-23 17:20:46 +01:00
parent ccfaefa361
commit 2fe0ec8c31

View file

@ -733,6 +733,12 @@ static int build_http_request(unsigned char *buf, size_t buf_size, size_t *reque
tail_len = strlen(GET_REQUEST_END);
if (opt.request_size != DFL_REQUEST_SIZE) {
request_size = (size_t) opt.request_size;
} else {
request_size = len + tail_len;
}
if (request_size > buf_size) {
return MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL;
}
/* Add padding to GET request to reach opt.request_size in length */