From: Daniel Stenberg Date: Sun, 5 Apr 2026 18:23:35 +0200 Subject: [PATCH] protocol: disable connection reuse for SMB(S) Connections should only be reused when using the same "share" (and perhaps some additional conditions), but instead of fixing this flaw, this change completely disables connection reuse for SMB. This protocol is about to get dropped soon anyway. Reported-by: Osama Hamad Closes #21238 Backported-by: Samuel Henrique * Upstream removes PROTOPT_CONN_REUSE from the SMB and SMBS scheme registrations in lib/protocol.c. That flag (and the lib/protocol.c scheme registry itself) only exists from upstream commit feea96851230c7a5a11feaffa0a5e4a4d30e5e63 ("conncontrol: reuse handling", Nov 2025) onward, so neither is present in 8.14.1. In 8.14.1 SMB connection reuse is instead controlled at runtime via connkeep() / connclose(), and lib/smb.c explicitly calls connkeep() in smb_connect() to mark SMB connections as eligible for reuse. Replace that connkeep() with a connclose() so SMB connections are marked as not-reusable, achieving the same effect as the upstream change. --- lib/smb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/smb.c b/lib/smb.c index d527977..3fd47ab 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -511,8 +511,10 @@ static CURLcode smb_connect(struct Curl_easy *data, bool *done) if(!smbc->send_buf) return CURLE_OUT_OF_MEMORY; - /* Multiple requests are allowed with this connection */ - connkeep(conn, "SMB default"); + /* SMB does not allow connection reuse: connections should only be reused + when using the same "share" (and possibly other conditions), but rather + than implementing that, mark every SMB connection as not reusable. */ + connclose(conn, "SMB does not allow connection reuse"); /* Parse the username, domain, and password */ slash = strchr(conn->user, '/');