The branch, master has been updated
       via  13521f85ad3 s3:auth: Fix Coverity ID 1646934: memory leak in 
make_pw_chat
      from  08d3de949af lib: Refactor fgets usage, fix resource leaks

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


- Log -----------------------------------------------------------------
commit 13521f85ad358010a0c1a43473e69060aff779fc
Author: Shachar Sharon <[email protected]>
Date:   Wed Jun 11 15:04:31 2025 +0300

    s3:auth: Fix Coverity ID 1646934: memory leak in make_pw_chat
    
    make_pw_chat may succeed in the first call to SMB_CALLOC_ARRAY but fail
    in one of the following loop iterations, in which the list is already
    populated with dynamically allocated entries. Make sure that we free the
    list before bailing out with NULL.
    
    Fixes Coverity issue 1646934
    
    Signed-off-by: Shachar Sharon <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Sat Jun 14 07:41:48 UTC 2025 on atb-devel-224

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

Summary of changes:
 source3/auth/pampass.c | 3 +++
 1 file changed, 3 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c
index 03d2fe69286..88a909b7bd2 100644
--- a/source3/auth/pampass.c
+++ b/source3/auth/pampass.c
@@ -223,6 +223,8 @@ struct chat_struct {
        fstring reply;
 };
 
+static void free_pw_chat(struct chat_struct *list);
+
 /**************************************************************
  Create a linked list containing chat data.
 ***************************************************************/
@@ -239,6 +241,7 @@ static struct chat_struct *make_pw_chat(const char *p)
                t = SMB_CALLOC_ARRAY(struct chat_struct, 1);
                if (!t) {
                        DEBUG(0,("make_pw_chat: malloc failed!\n"));
+                       free_pw_chat(list);
                        TALLOC_FREE(frame);
                        return NULL;
                }


-- 
Samba Shared Repository

Reply via email to