Skip to content

Commit 0911189

Browse files
committed
server session BUGFIX missing unlock
Fixes #320
1 parent c46b3df commit 0911189

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/session_server_ssh.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,24 +597,27 @@ nc_server_ssh_ch_client_endpt_set_auth_timeout(const char *client_name, const ch
597597
static int
598598
_nc_server_ssh_add_authkey(const char *pubkey_path, const char *pubkey_base64, NC_SSH_KEY_TYPE type, const char *username)
599599
{
600+
int ret = 0;
601+
600602
/* LOCK */
601603
pthread_mutex_lock(&server_opts.authkey_lock);
602604

603605
++server_opts.authkey_count;
604606
server_opts.authkeys = nc_realloc(server_opts.authkeys, server_opts.authkey_count * sizeof *server_opts.authkeys);
605607
if (!server_opts.authkeys) {
606608
ERRMEM;
607-
return -1;
609+
ret = -1;
610+
goto cleanup;
608611
}
609612
lydict_insert(server_opts.ctx, pubkey_path, 0, &server_opts.authkeys[server_opts.authkey_count - 1].path);
610613
lydict_insert(server_opts.ctx, pubkey_base64, 0, &server_opts.authkeys[server_opts.authkey_count - 1].base64);
611614
server_opts.authkeys[server_opts.authkey_count - 1].type = type;
612615
lydict_insert(server_opts.ctx, username, 0, &server_opts.authkeys[server_opts.authkey_count - 1].username);
613616

617+
cleanup:
614618
/* UNLOCK */
615619
pthread_mutex_unlock(&server_opts.authkey_lock);
616-
617-
return 0;
620+
return ret;
618621
}
619622

620623
API int

0 commit comments

Comments
 (0)