]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh2:ssh_connect: clear session pointer after free
authorDaniel Stenberg <daniel@haxx.se>
Sat, 20 Mar 2021 23:10:04 +0000 (00:10 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 21 Mar 2021 10:22:08 +0000 (11:22 +0100)
If libssh2_knownhost_init() returns NULL, like in an OOM situation, the
ssh session was freed but the pointer wasn't cleared which made libcurl
later call libssh2 to cleanup using the stale pointer.

Fixes #6764
Closes #6766

lib/vssh/libssh2.c

index 0e7c2eb987a782c33fb828281d0c3fa57bf9e76f..891e945f79de6a7b72a939e7ff9f032c9f9dddc1 100644 (file)
@@ -3159,6 +3159,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
     sshc->kh = libssh2_knownhost_init(sshc->ssh_session);
     if(!sshc->kh) {
       libssh2_session_free(sshc->ssh_session);
+      sshc->ssh_session = NULL;
       return CURLE_FAILED_INIT;
     }