mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-27 13:21:11 +03:00
buffer: Only allow to allocate a maximum of 256MB
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -52,6 +52,9 @@ struct ssh_buffer_struct {
|
||||
uint8_t *data;
|
||||
};
|
||||
|
||||
/* Buffer size maximum is 256M */
|
||||
#define BUFFER_SIZE_MAX 0x10000000
|
||||
|
||||
/**
|
||||
* @defgroup libssh_buffer The SSH buffer functions.
|
||||
* @ingroup libssh
|
||||
@@ -191,6 +194,10 @@ static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed)
|
||||
}
|
||||
needed = smallest;
|
||||
|
||||
if (needed > BUFFER_SIZE_MAX) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buffer->secure) {
|
||||
new = malloc(needed);
|
||||
if (new == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user