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 <samueloph@debian.org>
* 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.
Backported by: Samuel Henrique <samueloph@debian.org>
* Bookworm 7.88.1: same connkeep() call in smb_connect() at line
271. Apply the same connkeep() -> connclose() swap; this version
also lacks PROTOPT_CONN_REUSE so the runtime approach is the
only way to express "do not reuse this connection".
Gbp-Pq: Name CVE-2026-5773.patch
if(!smbc->recv_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, '/');