From 896bcd506866d3f119e23ec264c9d2150318cdf9 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 2 Apr 2022 16:13:27 +0100 Subject: [PATCH] Resurrect the test backends. I've been keeping them up to date with API changes as far as making sure they still _compile_, but today I tried to actually run them, and found that they were making a couple of segfault-inducing mistakes: not filling in their vtable pointer, and not returning a 'realhost' string. Now fixed. --- otherbackends/testback.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/otherbackends/testback.c b/otherbackends/testback.c index dbe282ec..f46d1d98 100644 --- a/otherbackends/testback.c +++ b/otherbackends/testback.c @@ -32,11 +32,8 @@ #include "putty.h" -static char *null_init(const BackendVtable *, Seat *, Backend **, LogContext *, - Conf *, const char *, int, char **, bool, bool); static char *loop_init(const BackendVtable *, Seat *, Backend **, LogContext *, Conf *, const char *, int, char **, bool, bool); -static void null_free(Backend *); static void loop_free(Backend *); static void null_reconfig(Backend *, Conf *); static void null_send(Backend *, const char *, size_t); @@ -55,8 +52,8 @@ static void null_unthrottle(Backend *, size_t); static int null_cfg_info(Backend *); const BackendVtable null_backend = { - .init = null_init, - .free = null_free, + .init = loop_init, + .free = loop_free, .reconfig = null_reconfig, .send = null_send, .sendbuffer = null_sendbuffer, @@ -106,17 +103,6 @@ struct loop_state { size_t sendbuffer; }; -static char *null_init(const BackendVtable *vt, Seat *seat, - Backend **backend_handle, LogContext *logctx, - Conf *conf, const char *host, int port, - char **realhost, bool nodelay, bool keepalive) { - /* No local authentication phase in this protocol */ - seat_set_trust_status(seat, false); - - *backend_handle = NULL; - return NULL; -} - static char *loop_init(const BackendVtable *vt, Seat *seat, Backend **backend_handle, LogContext *logctx, Conf *conf, const char *host, int port, @@ -127,15 +113,14 @@ static char *loop_init(const BackendVtable *vt, Seat *seat, seat_set_trust_status(seat, false); st->seat = seat; + st->backend.vt = vt; *backend_handle = &st->backend; + + *realhost = dupstr(host); + return NULL; } -static void null_free(Backend *be) -{ - -} - static void loop_free(Backend *be) { struct loop_state *st = container_of(be, struct loop_state, backend);