Skip to content

Instantly share code, notes, and snippets.

@xquery
Last active March 8, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xquery/c68fb35968b778ea3bf80081bab58532 to your computer and use it in GitHub Desktop.
Save xquery/c68fb35968b778ea3bf80081bab58532 to your computer and use it in GitHub Desktop.
diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
index 8e043747e..b349d7ba7 100644
--- a/lib/vssh/libssh2.c
+++ b/lib/vssh/libssh2.c
@@ -694,25 +694,27 @@ static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
while(!libssh2_knownhost_get(sshc->kh, &store, store)) {
/* For non-standard ports, the name will be enclosed in */
/* square brackets, followed by a colon and the port */
- if(store->name[0] == '[') {
- kh_name_end = strstr(store->name, "]:");
- if(!kh_name_end) {
- infof(data, "Invalid host pattern %s in %s\n",
- store->name, data->set.str[STRING_SSH_KNOWNHOSTS]);
- continue;
- }
- port = atoi(kh_name_end + 2);
- if(kh_name_end && (port == conn->remote_port)) {
- kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
- if(strncmp(store->name + 1, conn->host.name, kh_name_size) == 0) {
- found = true;
- break;
+ if(store->name != NULL) {
+ if(store->name[0] == '[') {
+ kh_name_end = strstr(store->name, "]:");
+ if(!kh_name_end) {
+ infof(data, "Invalid host pattern %s in %s\n", store->name,
+ data->set.str[STRING_SSH_KNOWNHOSTS]);
+ continue;
+ }
+ port = atoi(kh_name_end + 2);
+ if(kh_name_end && (port == conn->remote_port)) {
+ kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
+ if(strncmp(store->name + 1, conn->host.name, kh_name_size) == 0) {
+ found = true;
+ break;
+ }
}
}
- }
- else if(strcmp(store->name, conn->host.name) == 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment