1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Build outgoing SSH agent requests in a strbuf.

This simplifies the client code both in ssh.c and in the client side
of Pageant.

I've cheated a tiny bit by preparing agent requests in a strbuf that
has space reserved at the front for the packet frame, which makes life
easier for the code that sends them off.
This commit is contained in:
Simon Tatham
2018-05-24 13:18:13 +01:00
parent 8ce0a67028
commit 0c44fa85df
8 changed files with 155 additions and 184 deletions

View File

@ -31,7 +31,7 @@ void agent_cancel_query(agent_pending_query *q)
}
agent_pending_query *agent_query(
void *in, int inlen, void **out, int *outlen,
strbuf *query, void **out, int *outlen,
void (*callback)(void *, void *, int), void *callback_ctx)
{
HWND hwnd;
@ -47,6 +47,9 @@ agent_pending_query *agent_query(
*out = NULL;
*outlen = 0;
if (query->len > AGENT_MAX_MSGLEN)
return NULL; /* query too large */
hwnd = FindWindow("Pageant", "Pageant");
if (!hwnd)
return NULL; /* *out == NULL, so failure */
@ -93,7 +96,8 @@ agent_pending_query *agent_query(
return NULL; /* *out == NULL, so failure */
}
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0);
memcpy(p, in, inlen);
strbuf_finalise_agent_query(query);
memcpy(p, query->s, query->len);
cds.dwData = AGENT_COPYDATA_ID;
cds.cbData = 1 + strlen(mapname);
cds.lpData = mapname;