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:
parent
ccfaefa361
commit
2fe0ec8c31
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
tail_len = strlen(GET_REQUEST_END);
|
||||||
if (opt.request_size != DFL_REQUEST_SIZE) {
|
if (opt.request_size != DFL_REQUEST_SIZE) {
|
||||||
request_size = (size_t) opt.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 */
|
/* Add padding to GET request to reach opt.request_size in length */
|
||||||
|
|
Loading…
Reference in a new issue