1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00
putty-source/aqsync.c
Simon Tatham eb2fe29fc9 Make asynchronous agent_query() requests cancellable.
Now, instead of returning a boolean indicating whether the query has
completed or is still pending, agent_query() returns NULL to indicate
that the query _has_ completed, and if it hasn't, it returns a pointer
to a context structure representing the pending query, so that the
latter can be used to cancel the query if (for example) you later
decide you need to free the thing its callback was using as a context.

This should fix a potential race-condition segfault if you overload an
agent forwarding channel and then close it abruptly. (Which nobody
will be doing for sensible purposes, of course! But I ran across this
while stress-testing other aspects of agent forwarding.)
2017-01-29 20:25:04 +00:00

22 lines
545 B
C

/*
* aqsync.c: the agent_query_synchronous() wrapper function.
*
* This is a very small thing to have to put in its own module, but it
* wants to be shared between back ends, and exist in any SSH client
* program and also Pageant, and _nowhere else_ (because it pulls in
* the main agent_query).
*/
#include <assert.h>
#include "putty.h"
void agent_query_synchronous(void *in, int inlen, void **out, int *outlen)
{
agent_pending_query *pending;
pending = agent_query(in, inlen, out, outlen, NULL, 0);
assert(!pending);
}