1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

sshd: fixes

This commit is contained in:
Andy Green 2018-04-06 10:17:22 +08:00
parent 9a51bd0a63
commit e9931680c8
3 changed files with 19 additions and 12 deletions

View file

@ -299,7 +299,7 @@ ssh_ops_is_pubkey_authorized(const char *username, const char *type,
* <len32>E<len32>N that the peer sends us
*/
if (memcmp(peer, ps, peer_len)) {
lwsl_info("factors mismatch\n");
lwsl_info("%s: factors mismatch, rejecting key\n", __func__);
goto bail;
}

View file

@ -417,6 +417,8 @@ ssh_free(void *p)
free(p);
}
#define ssh_free_set_NULL(x) if (x) { ssh_free(x); (x) = NULL; }
static void
lws_ua_destroy(struct per_session_data__sshd *pss)
{
@ -1066,10 +1068,12 @@ again:
}
pss->seen_auth_req_before = 1;
lws_strncpy(pss->last_auth_req_username, pss->ua->username,
sizeof(pss->last_auth_req_username));
lws_strncpy(pss->last_auth_req_service, pss->ua->service,
sizeof(pss->last_auth_req_service));
lws_strncpy(pss->last_auth_req_username,
pss->ua->username,
sizeof(pss->last_auth_req_username));
lws_strncpy(pss->last_auth_req_service,
pss->ua->service,
sizeof(pss->last_auth_req_service));
if (strcmp(pss->ua->service, "ssh-connection"))
goto ua_fail;
@ -1357,7 +1361,7 @@ again:
pss->vhd->ops->disconnect_reason(
pss->disconnect_reason,
pss->disconnect_desc, pss->name);
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
break;
/*
@ -1519,7 +1523,7 @@ again:
if (pss->vhd->ops && pss->vhd->ops->pty_req)
n = pss->vhd->ops->pty_req(pss->ch_temp->priv,
&pss->args.pty);
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
if (n)
goto chrq_fail;
if (pss->rq_want_reply)
@ -1567,7 +1571,7 @@ again:
!pss->vhd->ops->exec(pss->ch_temp->priv, pss->wsi,
(const char *)pss->last_alloc,
lws_ssh_exec_finish, pss->ch_temp)) {
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
if (pss->rq_want_reply)
write_task_insert(pss, pss->ch_temp,
SSH_WT_CHRQ_SUCC);
@ -1590,7 +1594,7 @@ again:
/* disallow it */
n = 0;
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
if (!n)
goto chrq_fail;
@ -1624,7 +1628,7 @@ again:
n = 1;
}
#endif
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
// if (!n)
goto ch_fail;
#if 0
@ -1715,7 +1719,7 @@ again:
break;
}
if (pss->parser_state == SSHS_NVC_CD_DATA_ALLOC)
ssh_free(pss->last_alloc);
ssh_free_set_NULL(pss->last_alloc);
if (ch->peer_window_est < 32768) {
write_task(pss, ch, SSH_WT_WINDOW_ADJUST);
@ -2082,6 +2086,8 @@ lws_callback_raw_sshd(struct lws *wsi, enum lws_callback_reasons reason,
lws_kex_destroy(pss);
lws_ua_destroy(pss);
ssh_free_set_NULL(pss->last_alloc);
while (pss->ch_list)
ssh_destroy_channel(pss, pss->ch_list);
@ -2232,6 +2238,7 @@ lws_callback_raw_sshd(struct lws *wsi, enum lws_callback_reasons reason,
ps1 = sshd_zalloc(n);
if (!ps1)
goto bail;
ps = ps1;
pp = ps1 + 5;
*pp++ = SSH_MSG_USERAUTH_PK_OK;
if (lws_cstr(&pp, pss->ua->alg, 64)) {

View file

@ -377,7 +377,7 @@ ssh_cgi_env_add(struct sshd_instance_priv *priv, const char *name,
return 1;
}
pvo->value = malloc(strlen(name) + 1);
pvo->value = malloc(strlen(value) + 1);
if (!pvo->value) {
free((char *)pvo->name);
free(pvo);