mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
Tidy error handling and get rid of some commented out code
--HG-- extra : convert_revision : beb6fc766123135d5ae455ff7ad6b48d85386f62
This commit is contained in:
parent
8028e07815
commit
eef35883b7
@ -258,8 +258,8 @@ void cli_load_agent_keys(m_list *ret_list) {
|
|||||||
|
|
||||||
void agent_buf_sign(buffer *sigblob, sign_key *key,
|
void agent_buf_sign(buffer *sigblob, sign_key *key,
|
||||||
const unsigned char *data, unsigned int len) {
|
const unsigned char *data, unsigned int len) {
|
||||||
buffer *request_data = buf_new(MAX_PUBKEY_SIZE + len + 12);
|
buffer *request_data = NULL;
|
||||||
buffer *response;
|
buffer *response = NULL;
|
||||||
unsigned int keylen, siglen;
|
unsigned int keylen, siglen;
|
||||||
int packet_type;
|
int packet_type;
|
||||||
|
|
||||||
@ -269,19 +269,14 @@ void agent_buf_sign(buffer *sigblob, sign_key *key,
|
|||||||
string data
|
string data
|
||||||
uint32 flags
|
uint32 flags
|
||||||
*/
|
*/
|
||||||
/* We write the key, then figure how long it was and write that */
|
request_data = buf_new(MAX_PUBKEY_SIZE + len + 12);
|
||||||
//buf_putint(request_data, 0);
|
|
||||||
buf_put_pub_key(request_data, key, key->type);
|
buf_put_pub_key(request_data, key, key->type);
|
||||||
keylen = request_data->len - 4;
|
keylen = request_data->len - 4;
|
||||||
//buf_setpos(request_data, 0);
|
|
||||||
//buf_putint(request_data, keylen);
|
|
||||||
|
|
||||||
//buf_setpos(request_data, request_data->len);
|
|
||||||
buf_putstring(request_data, data, len);
|
buf_putstring(request_data, data, len);
|
||||||
buf_putint(request_data, 0);
|
buf_putint(request_data, 0);
|
||||||
|
|
||||||
response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data);
|
response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data);
|
||||||
buf_free(request_data);
|
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -298,14 +293,21 @@ void agent_buf_sign(buffer *sigblob, sign_key *key,
|
|||||||
*/
|
*/
|
||||||
siglen = buf_getint(response);
|
siglen = buf_getint(response);
|
||||||
buf_putbytes(sigblob, buf_getptr(response, siglen), siglen);
|
buf_putbytes(sigblob, buf_getptr(response, siglen), siglen);
|
||||||
buf_free(response);
|
goto cleanup;
|
||||||
|
|
||||||
return;
|
|
||||||
fail:
|
fail:
|
||||||
/* XXX don't fail badly here. instead propagate a failure code back up to
|
/* XXX don't fail badly here. instead propagate a failure code back up to
|
||||||
the cli auth pubkey code, and just remove this key from the list of
|
the cli auth pubkey code, and just remove this key from the list of
|
||||||
ones to try. */
|
ones to try. */
|
||||||
dropbear_exit("Agent failed signing key");
|
dropbear_exit("Agent failed signing key");
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (request_data) {
|
||||||
|
buf_free(request_data);
|
||||||
|
}
|
||||||
|
if (response) {
|
||||||
|
buf_free(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user