aboutsummaryrefslogtreecommitdiffstats
path: root/agent/command-ssh.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-03-23 12:42:53 +0000
committerWerner Koch <[email protected]>2014-03-23 12:42:53 +0000
commit5c2a50cdc90e85b1fc380851ccfbe9186969b658 (patch)
treedad9d522020816378049190d865469633d234618 /agent/command-ssh.c
parentagent: Put ssh key type as comment into sshcontrol. (diff)
downloadgnupg-5c2a50cdc90e85b1fc380851ccfbe9186969b658.tar.gz
gnupg-5c2a50cdc90e85b1fc380851ccfbe9186969b658.zip
agent: Replace es_mopen by es_fopenmem for ssh.
* agent/command-ssh.c (ssh_read_key_public_from_blob): Use es_fopenmem. (ssh_handler_request_identities): Ditto. (ssh_request_process): Ditto. -- es_fopenmem is easier to understand than the more general function es_mopen. Thus we better use the former for clarity.
Diffstat (limited to 'agent/command-ssh.c')
-rw-r--r--agent/command-ssh.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index 5d7186f83..04fe049a2 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -2368,13 +2368,11 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
gcry_sexp_t *key_public,
ssh_key_type_spec_t *key_spec)
{
- estream_t blob_stream;
gpg_error_t err;
+ estream_t blob_stream;
- err = 0;
- /* FIXME: Use fopenmem_init */
- blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
- if (! blob_stream)
+ blob_stream = es_fopenmem (0, "r+b");
+ if (!blob_stream)
{
err = gpg_error_from_syserror ();
goto out;
@@ -2391,10 +2389,7 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
err = ssh_receive_key (blob_stream, key_public, 0, 0, key_spec);
out:
-
- if (blob_stream)
- es_fclose (blob_stream);
-
+ es_fclose (blob_stream);
return err;
}
@@ -2619,7 +2614,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
key_counter = 0;
err = 0;
- key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+b");
+ key_blobs = es_fopenmem (0, "r+b");
if (! key_blobs)
{
err = gpg_error_from_syserror ();
@@ -3447,21 +3442,16 @@ static int
ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
{
ssh_request_spec_t *spec;
- estream_t response;
- estream_t request;
+ estream_t response = NULL;
+ estream_t request = NULL;
unsigned char request_type;
gpg_error_t err;
- int send_err;
+ int send_err = 0;
int ret;
- unsigned char *request_data;
+ unsigned char *request_data = NULL;
u32 request_data_size;
u32 response_size;
- request_data = NULL;
- response = NULL;
- request = NULL;
- send_err = 0;
-
/* Create memory streams for request/response data. The entire
request will be stored in secure memory, since it might contain
secret key material. The response does not have to be stored in
@@ -3500,9 +3490,9 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
}
if (spec->secret_input)
- request = es_mopen (NULL, 0, 0, 1, realloc_secure, gcry_free, "r+");
+ request = es_mopen (NULL, 0, 0, 1, realloc_secure, gcry_free, "r+b");
else
- request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+");
+ request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+b");
if (! request)
{
err = gpg_error_from_syserror ();
@@ -3519,7 +3509,7 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
goto out;
es_rewind (request);
- response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
+ response = es_fopenmem (0, "r+b");
if (! response)
{
err = gpg_error_from_syserror ();
@@ -3595,11 +3585,9 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
leave:
- if (request)
- es_fclose (request);
- if (response)
- es_fclose (response);
- xfree (request_data); /* FIXME? */
+ es_fclose (request);
+ es_fclose (response);
+ xfree (request_data);
return !!err;
}