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