agent: make the code better deal with unexpected code flows
agent->ops gets initialized by the libssh2_agent_connect() call but we need to make sure that we don't segfault even if a bad sequence of function calls is used.
This commit is contained in:
parent
c87a48ae4c
commit
3490b3fe10
14
src/agent.c
14
src/agent.c
@ -376,9 +376,12 @@ agent_sign(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
}
|
||||
|
||||
/* Make sure to be re-called as a result of EAGAIN. */
|
||||
if (*transctx->request != SSH2_AGENTC_SIGN_REQUEST) {
|
||||
if (*transctx->request != SSH2_AGENTC_SIGN_REQUEST)
|
||||
return LIBSSH2_ERROR_BAD_USE;
|
||||
|
||||
if (!agent->ops)
|
||||
/* if no agent has been connected, bail out */
|
||||
return LIBSSH2_ERROR_BAD_USE;
|
||||
}
|
||||
|
||||
rc = agent->ops->transact(agent, transctx);
|
||||
if (rc) {
|
||||
@ -471,9 +474,12 @@ agent_list_identities(LIBSSH2_AGENT *agent)
|
||||
}
|
||||
|
||||
/* Make sure to be re-called as a result of EAGAIN. */
|
||||
if (*transctx->request != SSH2_AGENTC_REQUEST_IDENTITIES) {
|
||||
if (*transctx->request != SSH2_AGENTC_REQUEST_IDENTITIES)
|
||||
return LIBSSH2_ERROR_BAD_USE;
|
||||
|
||||
if (!agent->ops)
|
||||
/* if no agent has been connected, bail out */
|
||||
return LIBSSH2_ERROR_BAD_USE;
|
||||
}
|
||||
|
||||
rc = agent->ops->transact(agent, transctx);
|
||||
if (rc) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user