1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

buffer: Do not call memcpy with null arguments

This allows compiling and testing with undefined sanitizer.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Nikos Mavrogiannopoulos
2018-04-18 09:09:05 +02:00
committed by Andreas Schneider
parent 87b8d232bd
commit eb796b4bbb

View File

@@ -145,9 +145,11 @@ static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed) {
if (new == NULL) {
return -1;
}
memcpy(new, buffer->data,buffer->used);
explicit_bzero(buffer->data, buffer->used);
SAFE_FREE(buffer->data);
if (buffer->used > 0) {
memcpy(new, buffer->data,buffer->used);
explicit_bzero(buffer->data, buffer->used);
SAFE_FREE(buffer->data);
}
} else {
new = realloc(buffer->data, needed);
if (new == NULL) {