[SCM] Samba Shared Repository - branch master updated

Anoop C S anoopcs at samba.org
Thu Sep 11 13:30:01 UTC 2025


The branch, master has been updated
       via  3e128df1ef4 samr: Fix CID 1035506: close slave fd (REASOURCE_LEAK)
      from  6cf1bf540e7 selftest: Do not use wrappers for samba.tests.docs

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 3e128df1ef4ce6f633aa61a7141a9998cd7d13bc
Author: Shachar Sharon <ssharon at redhat.com>
Date:   Tue Aug 19 11:34:13 2025 +0300

    samr: Fix CID 1035506: close slave fd (REASOURCE_LEAK)
    
    In the case of (unlikely) failure of dup2 on one of the standard file
    descriptors, close 'slave' fd upon return.
    
    Signed-off-by: Shachar Sharon <ssharon at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Anoop C S <anoopcs at samba.org>
    
    Autobuild-User(master): Anoop C S <anoopcs at samba.org>
    Autobuild-Date(master): Thu Sep 11 13:29:37 UTC 2025 on atb-devel-224

-----------------------------------------------------------------------

Summary of changes:
 source3/rpc_server/samr/srv_samr_chgpasswd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/rpc_server/samr/srv_samr_chgpasswd.c b/source3/rpc_server/samr/srv_samr_chgpasswd.c
index 6c0c0da0cfc..000f6c2b87d 100644
--- a/source3/rpc_server/samr/srv_samr_chgpasswd.c
+++ b/source3/rpc_server/samr/srv_samr_chgpasswd.c
@@ -201,18 +201,24 @@ static int dochild(int master, const char *slavedev, const struct passwd *pass,
 
 	/* Make slave stdin/out/err of child. */
 
-	if (dup2(slave, STDIN_FILENO) != STDIN_FILENO)
+	if ((slave != STDIN_FILENO) &&
+	    (dup2(slave, STDIN_FILENO) != STDIN_FILENO))
 	{
+		close(slave);
 		DEBUG(3, ("Could not re-direct stdin\n"));
 		return (False);
 	}
-	if (dup2(slave, STDOUT_FILENO) != STDOUT_FILENO)
+	if ((slave != STDOUT_FILENO) &&
+	    (dup2(slave, STDOUT_FILENO) != STDOUT_FILENO))
 	{
+		close(slave);
 		DEBUG(3, ("Could not re-direct stdout\n"));
 		return (False);
 	}
-	if (dup2(slave, STDERR_FILENO) != STDERR_FILENO)
+	if ((slave != STDERR_FILENO) &&
+	    (dup2(slave, STDERR_FILENO) != STDERR_FILENO))
 	{
+		close(slave);
 		DEBUG(3, ("Could not re-direct stderr\n"));
 		return (False);
 	}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list