From d61897414cae6e40dc39da6aac84ab48c6cdf149 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 20 Jun 2017 21:17:43 +0100 Subject: [PATCH] Fixes spotted by Coverity. A lenof() being applied to a non-array, a couple of missing frees on an error path, and a case in pfd_receive() where we could have gone round a loop again after freeing the port forwarding structure it was working on. --- config.c | 2 +- portfwd.c | 1 + psftp.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 220c1aa8..efe1ff1e 100644 --- a/config.c +++ b/config.c @@ -1005,7 +1005,7 @@ static void ttymodes_handler(union control *ctrl, void *dlg, char type; { - const char *types = "ANV"; + const char types[] = {'A', 'N', 'V'}; int button = dlg_radiobutton_get(td->valradio, dlg); assert(button >= 0 && button < lenof(types)); type = types[button]; diff --git a/portfwd.c b/portfwd.c index febd8af9..b68e4bb8 100644 --- a/portfwd.c +++ b/portfwd.c @@ -359,6 +359,7 @@ static void pfd_receive(Plug plug, int urgent, char *data, int len) * close the connection rudely. */ pfd_close(pf); + break; } return; diff --git a/psftp.c b/psftp.c index aa397181..e4e77c3a 100644 --- a/psftp.c +++ b/psftp.c @@ -1050,6 +1050,8 @@ int sftp_cmd_ls(struct sftp_command *cmd) if (dirh == NULL) { printf("Unable to open %s: %s\n", dir, fxp_error()); + sfree(cdir); + sfree(unwcdir); return 0; } else { nnames = namesize = 0;