mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-08 08:58:00 +00:00
99b4229abf
Commit 8f5e9a4f8d
introduced a segfault into both Windows Pageant
and Windows connection sharing upstreams when they receive an incoming
named-pipe connection. This occurs because the PlugVtables for those
incoming connections had a null pointer in the 'log' field, because
hitherto, only sockets involved with an outgoing connection expected
to receive plug_log() notifications. But I added such a notification
in make_handle_socket, forgetting that that function is used for both
outgoing and incoming named-pipe connections (among other things). So
now a Plug implementation that expects to be set up by the
plug_accepting() method on a listener may still receive
PLUGLOG_CONNECT_SUCCESS.
I could fix that by adding a parameter to make_handle_socket telling
it whether to send a notification, but that seems like more faff than
is really needed. Simpler to make a rule that says _all_ Socket types
must implement the log() method, even if only with a no-op function.
We already have a no-op implementation of log(), in nullplug.c. So
I've exposed that outside its module (in the same style as all the
nullseat functions and so on), to make it really easy to add log()
methods to PlugVtables that don't need one.
42 lines
1.0 KiB
C
42 lines
1.0 KiB
C
/*
|
|
* nullplug.c: provide a null implementation of the Plug vtable which
|
|
* ignores all calls. Occasionally useful in cases where we want to
|
|
* make a network connection just to see if it works, but not do
|
|
* anything with it afterwards except close it again.
|
|
*/
|
|
|
|
#include "putty.h"
|
|
|
|
void nullplug_log(Plug *plug, PlugLogType type, SockAddr *addr,
|
|
int port, const char *err_msg, int err_code)
|
|
{
|
|
}
|
|
|
|
void nullplug_closing(Plug *plug, const char *error_msg, int error_code,
|
|
bool calling_back)
|
|
{
|
|
}
|
|
|
|
void nullplug_receive(Plug *plug, int urgent, const char *data, size_t len)
|
|
{
|
|
}
|
|
|
|
void nullplug_sent(Plug *plug, size_t bufsize)
|
|
{
|
|
}
|
|
|
|
static const PlugVtable nullplug_plugvt = {
|
|
.log = nullplug_log,
|
|
.closing = nullplug_closing,
|
|
.receive = nullplug_receive,
|
|
.sent = nullplug_sent,
|
|
};
|
|
|
|
static Plug nullplug_plug = { &nullplug_plugvt };
|
|
|
|
/*
|
|
* There's a singleton instance of nullplug, because it's not
|
|
* interesting enough to worry about making more than one of them.
|
|
*/
|
|
Plug *const nullplug = &nullplug_plug;
|