mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
buffers: Fix a possible null pointer dereference
This is an addition to CVE-2015-3146 to fix the null pointer dereference. The patch is not required to fix the CVE but prevents issues in future. Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
bf0c7ae0ae
commit
3091025472
@@ -224,6 +224,10 @@ int ssh_buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint
|
|||||||
{
|
{
|
||||||
buffer_verify(buffer);
|
buffer_verify(buffer);
|
||||||
|
|
||||||
|
if (data == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (buffer->used + len < len) {
|
if (buffer->used + len < len) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -257,6 +261,10 @@ int buffer_add_ssh_string(struct ssh_buffer_struct *buffer,
|
|||||||
struct ssh_string_struct *string) {
|
struct ssh_string_struct *string) {
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
|
|
||||||
|
if (string == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
len = ssh_string_len(string);
|
len = ssh_string_len(string);
|
||||||
if (ssh_buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {
|
if (ssh_buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user