mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +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;
|
uint8_t *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Buffer size maximum is 256M */
|
||||||
|
#define BUFFER_SIZE_MAX 0x10000000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup libssh_buffer The SSH buffer functions.
|
* @defgroup libssh_buffer The SSH buffer functions.
|
||||||
* @ingroup libssh
|
* @ingroup libssh
|
||||||
@@ -191,6 +194,10 @@ static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed)
|
|||||||
}
|
}
|
||||||
needed = smallest;
|
needed = smallest;
|
||||||
|
|
||||||
|
if (needed > BUFFER_SIZE_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (buffer->secure) {
|
if (buffer->secure) {
|
||||||
new = malloc(needed);
|
new = malloc(needed);
|
||||||
if (new == NULL) {
|
if (new == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user