Blob Blame History Raw
From 526816eb2216159fccb245293d2cfb13ea97dfa9 Mon Sep 17 00:00:00 2001
From: TJ Saunders <tj@castaglia.org>
Date: Tue, 17 May 2016 12:30:59 -0700
Subject: [PATCH] Defensively clear the response lists before each SFTP
 request, having just tracked down a segfault caused by NOT doing this
 properly in a previous version of ProFTPD.

---
 contrib/mod_sftp/fxp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/contrib/mod_sftp/fxp.c b/contrib/mod_sftp/fxp.c
index 15b7d00..fb4f106 100644
--- a/contrib/mod_sftp/fxp.c
+++ b/contrib/mod_sftp/fxp.c
@@ -13561,6 +13561,12 @@ int sftp_fxp_handle_packet(pool *p, void *ssh2, uint32_t channel_id,
 
     pr_response_set_pool(fxp->pool);
 
+    /* Make sure to clear the response lists of any cruft from previous
+     * requests.
+     */
+    pr_response_clear(&resp_list);
+    pr_response_clear(&resp_err_list);
+
     switch (fxp->request_type) {
       case SFTP_SSH2_FXP_INIT:
         /* If we already know the version, then the client has sent