1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

src: check for NULL pointer passed to _libssh2_get_string

Callers should be protecting against this, but it's prudent to check
here anyway.

Fixes #802
Closes #848
This commit is contained in:
Dan Fandrich
2023-03-14 11:18:58 -07:00
parent f928da9f95
commit 289b4a1c0c

View File

@@ -834,7 +834,7 @@ int _libssh2_get_string(struct string_buf *buf, unsigned char **outbuf,
size_t *outlen)
{
uint32_t data_len;
if(_libssh2_get_u32(buf, &data_len) != 0) {
if(!buf || _libssh2_get_u32(buf, &data_len) != 0) {
return -1;
}
if(!_libssh2_check_length(buf, data_len)) {