]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: guard lp_killservice() in delete_and_reload_printers() with connections_snum...
authorJeremy Allison <jallison@ciq.com>
Fri, 10 Apr 2026 21:21:55 +0000 (14:21 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 14 Apr 2026 23:04:37 +0000 (23:04 +0000)
delete_and_reload_printers() unconditionally calls lp_killservice()
to destroy autoloaded printer services that are no longer in the
printer list. If any active connection is still using the printer
service number, the destroyed service can cause a NULL pointer
dereference on subsequent requests.

Guard the call with connections_snum_used() so the service is only
freed when no connections are using it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14978

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
source3/smbd/server_reload.c

index d3322d12f6aaea623a897ada22fc355de46de999..eba87cc98ca770132bb291b936b83d45909c63b9 100644 (file)
@@ -109,7 +109,8 @@ void delete_and_reload_printers(void)
 
                /* check printer, but avoid removing non-autoloaded printers */
                if (lp_autoloaded(snum) &&
-                   !printer_list_printername_exists(pname)) {
+                   !printer_list_printername_exists(pname) &&
+                   !connections_snum_used(NULL, snum)) {
                        lp_killservice(snum);
                }
        }