diff --git a/errsock.c b/errsock.c index 14e66456..4f640a66 100644 --- a/errsock.c +++ b/errsock.c @@ -39,16 +39,11 @@ static const char *sk_error_socket_error(Socket *s) return es->error; } -static SocketEndpointInfo *sk_error_endpoint_info(Socket *s, bool peer) -{ - return NULL; -} - static const SocketVtable ErrorSocket_sockvt = { .plug = sk_error_plug, .close = sk_error_close, .socket_error = sk_error_socket_error, - .endpoint_info = sk_error_endpoint_info, + .endpoint_info = nullsock_endpoint_info, /* other methods are NULL */ }; diff --git a/network.h b/network.h index ac0a63d0..ae56ba4a 100644 --- a/network.h +++ b/network.h @@ -386,6 +386,11 @@ void nullplug_closing(Plug *plug, PlugCloseType type, const char *error_msg); void nullplug_receive(Plug *plug, int urgent, const char *data, size_t len); void nullplug_sent(Plug *plug, size_t bufsize); +/* + * Similar no-op socket function. + */ +SocketEndpointInfo *nullsock_endpoint_info(Socket *s, bool peer); + /* ---------------------------------------------------------------------- * Functions defined outside the network code, which have to be * declared in this header file rather than the main putty.h because diff --git a/proxy/sshproxy.c b/proxy/sshproxy.c index ce422dd5..0958c3cd 100644 --- a/proxy/sshproxy.c +++ b/proxy/sshproxy.c @@ -123,11 +123,6 @@ static const char *sshproxy_socket_error(Socket *s) return sp->errmsg; } -static SocketEndpointInfo *sshproxy_endpoint_info(Socket *s, bool peer) -{ - return NULL; -} - static const SocketVtable SshProxy_sock_vt = { .plug = sshproxy_plug, .close = sshproxy_close, @@ -136,7 +131,7 @@ static const SocketVtable SshProxy_sock_vt = { .write_eof = sshproxy_write_eof, .set_frozen = sshproxy_set_frozen, .socket_error = sshproxy_socket_error, - .endpoint_info = sshproxy_endpoint_info, + .endpoint_info = nullsock_endpoint_info, }; static void sshproxy_eventlog(LogPolicy *lp, const char *event) diff --git a/ssh/portfwd.c b/ssh/portfwd.c index 470c090d..bac20e05 100644 --- a/ssh/portfwd.c +++ b/ssh/portfwd.c @@ -96,20 +96,6 @@ static void free_portlistener_state(struct PortListener *pl) sfree(pl); } -static void pfd_log(Plug *plug, Socket *s, PlugLogType type, - SockAddr *addr, int port, - const char *error_msg, int error_code) -{ - /* we have to dump these since we have no interface to logging.c */ -} - -static void pfl_log(Plug *plug, Socket *s, PlugLogType type, - SockAddr *addr, int port, - const char *error_msg, int error_code) -{ - /* we have to dump these since we have no interface to logging.c */ -} - static void pfd_close(struct PortForwarding *pf); static void pfd_closing(Plug *plug, PlugCloseType type, const char *error_msg) @@ -433,7 +419,7 @@ static void pfd_sent(Plug *plug, size_t bufsize) } static const PlugVtable PortForwarding_plugvt = { - .log = pfd_log, + .log = nullplug_log, .closing = pfd_closing, .receive = pfd_receive, .sent = pfd_sent, @@ -556,7 +542,7 @@ static int pfl_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) } static const PlugVtable PortListener_plugvt = { - .log = pfl_log, + .log = nullplug_log, .closing = pfl_closing, .accepting = pfl_accepting, }; diff --git a/ssh/server.c b/ssh/server.c index bd8b70db..97fc5841 100644 --- a/ssh/server.c +++ b/ssh/server.c @@ -138,14 +138,6 @@ static const SeatVtable server_seat_vt = { .get_cursor_position = nullseat_get_cursor_position, }; -static void server_socket_log(Plug *plug, Socket *s, PlugLogType type, - SockAddr *addr, int port, - const char *error_msg, int error_code) -{ - /* server *srv = container_of(plug, server, plug); */ - /* FIXME */ -} - static void server_closing(Plug *plug, PlugCloseType type, const char *error_msg) { @@ -254,7 +246,7 @@ Conf *make_ssh_server_conf(void) void ssh_check_sendok(Ssh *ssh) {} static const PlugVtable ssh_server_plugvt = { - .log = server_socket_log, + .log = nullplug_log, .closing = server_closing, .receive = server_receive, .sent = server_sent, diff --git a/ssh/sesschan.c b/ssh/sesschan.c index f4b44069..cc50fd5c 100644 --- a/ssh/sesschan.c +++ b/ssh/sesschan.c @@ -371,12 +371,6 @@ bool sesschan_run_subsystem(Channel *chan, ptrlen subsys) return false; } -static void fwd_log(Plug *plug, Socket *s, PlugLogType type, SockAddr *addr, - int port, const char *error_msg, int error_code) -{ /* don't expect any weirdnesses from a listening socket */ } -static void fwd_closing(Plug *plug, PlugCloseType type, const char *error_msg) -{ /* not here, either */ } - static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) { sesschan *sess = container_of(p, sesschan, xfwd_plug); @@ -400,8 +394,8 @@ static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx) } static const PlugVtable xfwd_plugvt = { - .log = fwd_log, - .closing = fwd_closing, + .log = nullplug_log, + .closing = nullplug_closing, .accepting = xfwd_accepting, }; @@ -473,8 +467,8 @@ static int agentfwd_accepting( } static const PlugVtable agentfwd_plugvt = { - .log = fwd_log, - .closing = fwd_closing, + .log = nullplug_log, + .closing = nullplug_closing, .accepting = agentfwd_accepting, }; diff --git a/ssh/x11fwd.c b/ssh/x11fwd.c index a9b049ea..88bdaffe 100644 --- a/ssh/x11fwd.c +++ b/ssh/x11fwd.c @@ -277,12 +277,6 @@ static char *x11_verify(unsigned long peer_ip, int peer_port, return NULL; } -static void x11_log(Plug *p, Socket *s, PlugLogType type, SockAddr *addr, - int port, const char *error_msg, int error_code) -{ - /* We have no interface to the logging module here, so we drop these. */ -} - static void x11_send_init_error(struct X11Connection *conn, const char *err_message); @@ -336,7 +330,7 @@ static void x11_sent(Plug *plug, size_t bufsize) } static const PlugVtable X11Connection_plugvt = { - .log = x11_log, + .log = nullplug_log, .closing = x11_closing, .receive = x11_receive, .sent = x11_sent, diff --git a/stubs/CMakeLists.txt b/stubs/CMakeLists.txt index dc02aca3..0b702853 100644 --- a/stubs/CMakeLists.txt +++ b/stubs/CMakeLists.txt @@ -28,4 +28,5 @@ add_sources_from_current_dir(utils null-mac.c null-opener.c null-plug.c - null-seat.c) + null-seat.c + null-socket.c) diff --git a/stubs/null-socket.c b/stubs/null-socket.c new file mode 100644 index 00000000..ef194824 --- /dev/null +++ b/stubs/null-socket.c @@ -0,0 +1,12 @@ +/* + * null-socket.c: provide a null implementation of any Socket vtable + * method that might otherwise need to be reimplemented in multiple + * places as a no-op. + */ + +#include "putty.h" + +SocketEndpointInfo *nullsock_endpoint_info(Socket *s, bool peer) +{ + return NULL; +} diff --git a/unix/fd-socket.c b/unix/fd-socket.c index e6f7c1c1..0f1615ef 100644 --- a/unix/fd-socket.c +++ b/unix/fd-socket.c @@ -315,11 +315,6 @@ static void fdsocket_select_result_input_error(int fd, int event) } } -static SocketEndpointInfo *fdsocket_endpoint_info(Socket *s, bool peer) -{ - return NULL; -} - static const SocketVtable FdSocket_sockvt = { .plug = fdsocket_plug, .close = fdsocket_close, @@ -328,7 +323,7 @@ static const SocketVtable FdSocket_sockvt = { .write_eof = fdsocket_write_eof, .set_frozen = fdsocket_set_frozen, .socket_error = fdsocket_socket_error, - .endpoint_info = fdsocket_endpoint_info, + .endpoint_info = nullsock_endpoint_info, }; static void fdsocket_connect_success_callback(void *ctx) diff --git a/unix/pageant.c b/unix/pageant.c index e53cec23..dadbc229 100644 --- a/unix/pageant.c +++ b/unix/pageant.c @@ -237,18 +237,12 @@ void keylist_update(void) static bool time_to_die = false; -/* - * These functions are part of the plug for our connection to the X - * display, so they do get called. They needn't actually do anything, - * except that x11_closing has to signal back to the main loop that - * it's time to terminate. - */ -static void x11_log(Plug *p, Socket *s, PlugLogType type, SockAddr *addr, - int port, const char *error_msg, int error_code) {} -static void x11_receive(Plug *plug, int urgent, const char *data, size_t len) {} -static void x11_sent(Plug *plug, size_t bufsize) {} static void x11_closing(Plug *plug, PlugCloseType type, const char *error_msg) { + /* + * When the X connection closes, signal back to the main loop that + * it's time to terminate. + */ time_to_die = true; } struct X11Connection { @@ -994,10 +988,10 @@ void run_client(void) } static const PlugVtable X11Connection_plugvt = { - .log = x11_log, + .log = nullplug_log, .closing = x11_closing, - .receive = x11_receive, - .sent = x11_sent, + .receive = nullplug_receive, + .sent = nullplug_sent, }; diff --git a/windows/named-pipe-server.c b/windows/named-pipe-server.c index b6a900db..24f0c8d9 100644 --- a/windows/named-pipe-server.c +++ b/windows/named-pipe-server.c @@ -63,12 +63,6 @@ static const char *sk_namedpipeserver_socket_error(Socket *s) return ps->error; } -static SocketEndpointInfo *sk_namedpipeserver_endpoint_info( - Socket *s, bool peer) -{ - return NULL; -} - static bool create_named_pipe(NamedPipeServerSocket *ps, bool first_instance) { SECURITY_ATTRIBUTES sa; @@ -197,7 +191,7 @@ static const SocketVtable NamedPipeServerSocket_sockvt = { .plug = sk_namedpipeserver_plug, .close = sk_namedpipeserver_close, .socket_error = sk_namedpipeserver_socket_error, - .endpoint_info = sk_namedpipeserver_endpoint_info, + .endpoint_info = nullsock_endpoint_info, }; Socket *new_named_pipe_listener(const char *pipename, Plug *plug)