From 289b4a1c0c939ffa58a6ece22a70559ceea882d1 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 14 Mar 2023 11:18:58 -0700 Subject: [PATCH] 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 --- src/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc.c b/src/misc.c index 74a6d5a7..a262e09d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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)) {