7d7193
From 5cdcf1dbd39c64e18a81fc912a36942a3ec87565 Mon Sep 17 00:00:00 2001
7d7193
From: Daniel Stenberg <daniel@haxx.se>
7d7193
Date: Mon, 19 Dec 2022 08:38:37 +0100
7d7193
Subject: [PATCH] smb/telnet: do not free the protocol struct in *_done()
7d7193
7d7193
It is managed by the generic layer.
7d7193
7d7193
Reported-by: Trail of Bits
7d7193
7d7193
Closes #10112
7d7193
7d7193
Upstream-commit: 4f20188ac644afe174be6005ef4f6ffba232b8b2
7d7193
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
7d7193
---
7d7193
 lib/smb.c    | 14 ++------------
7d7193
 lib/telnet.c |  3 ---
7d7193
 2 files changed, 2 insertions(+), 15 deletions(-)
7d7193
7d7193
diff --git a/lib/smb.c b/lib/smb.c
7d7193
index 039d680..f682c1f 100644
7d7193
--- a/lib/smb.c
7d7193
+++ b/lib/smb.c
7d7193
@@ -61,8 +61,6 @@ static CURLcode smb_connect(struct connectdata *conn, bool *done);
7d7193
 static CURLcode smb_connection_state(struct connectdata *conn, bool *done);
7d7193
 static CURLcode smb_do(struct connectdata *conn, bool *done);
7d7193
 static CURLcode smb_request_state(struct connectdata *conn, bool *done);
7d7193
-static CURLcode smb_done(struct connectdata *conn, CURLcode status,
7d7193
-                         bool premature);
7d7193
 static CURLcode smb_disconnect(struct connectdata *conn, bool dead);
7d7193
 static int smb_getsock(struct connectdata *conn, curl_socket_t *socks,
7d7193
                        int numsocks);
7d7193
@@ -75,7 +73,7 @@ const struct Curl_handler Curl_handler_smb = {
7d7193
   "SMB",                                /* scheme */
7d7193
   smb_setup_connection,                 /* setup_connection */
7d7193
   smb_do,                               /* do_it */
7d7193
-  smb_done,                             /* done */
7d7193
+  ZERO_NULL,                            /* done */
7d7193
   ZERO_NULL,                            /* do_more */
7d7193
   smb_connect,                          /* connect_it */
7d7193
   smb_connection_state,                 /* connecting */
7d7193
@@ -100,7 +98,7 @@ const struct Curl_handler Curl_handler_smbs = {
7d7193
   "SMBS",                               /* scheme */
7d7193
   smb_setup_connection,                 /* setup_connection */
7d7193
   smb_do,                               /* do_it */
7d7193
-  smb_done,                             /* done */
7d7193
+  ZERO_NULL,                            /* done */
7d7193
   ZERO_NULL,                            /* do_more */
7d7193
   smb_connect,                          /* connect_it */
7d7193
   smb_connection_state,                 /* connecting */
7d7193
@@ -915,14 +913,6 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
7d7193
   return CURLE_OK;
7d7193
 }
7d7193
 
7d7193
-static CURLcode smb_done(struct connectdata *conn, CURLcode status,
7d7193
-                         bool premature)
7d7193
-{
7d7193
-  (void) premature;
7d7193
-  Curl_safefree(conn->data->req.protop);
7d7193
-  return status;
7d7193
-}
7d7193
-
7d7193
 static CURLcode smb_disconnect(struct connectdata *conn, bool dead)
7d7193
 {
7d7193
   struct smb_conn *smbc = &conn->proto.smbc;
7d7193
diff --git a/lib/telnet.c b/lib/telnet.c
7d7193
index 923c7f8..48cd0d7 100644
7d7193
--- a/lib/telnet.c
7d7193
+++ b/lib/telnet.c
7d7193
@@ -1294,9 +1294,6 @@ static CURLcode telnet_done(struct connectdata *conn,
7d7193
 
7d7193
   curl_slist_free_all(tn->telnet_vars);
7d7193
   tn->telnet_vars = NULL;
7d7193
-
7d7193
-  Curl_safefree(conn->data->req.protop);
7d7193
-
7d7193
   return CURLE_OK;
7d7193
 }
7d7193
 
7d7193
-- 
7d7193
2.38.1
7d7193