diff options
author | Samuel Cabrero <scabrero@suse.de> | 2022-06-13 13:56:10 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-06-27 15:50:30 +0000 |
commit | d64335eaef5ad690ea923a8e6656b9185a54d9fa (patch) | |
tree | 4b4ac7870c47207d7db997bb33fef581cf77d268 /libgpo/pygpo.c | |
parent | c1ab39163bbaf8ef9c8dc92b1d14c3f6cb56456c (diff) | |
download | samba-d64335eaef5ad690ea923a8e6656b9185a54d9fa.tar.gz |
s3:libads: Allocate ads->auth.password under ADS_STRUCT talloc context
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'libgpo/pygpo.c')
-rw-r--r-- | libgpo/pygpo.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index 85a4aaa1581..b9570b24d82 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -230,13 +230,17 @@ static PyObject* py_ads_connect(ADS *self, return NULL; } SAFE_FREE(self->ads_ptr->auth.user_name); - SAFE_FREE(self->ads_ptr->auth.password); + TALLOC_FREE(self->ads_ptr->auth.password); TALLOC_FREE(self->ads_ptr->auth.realm); if (self->cli_creds) { self->ads_ptr->auth.user_name = SMB_STRDUP(cli_credentials_get_username(self->cli_creds)); - self->ads_ptr->auth.password = - SMB_STRDUP(cli_credentials_get_password(self->cli_creds)); + self->ads_ptr->auth.password = talloc_strdup(self->ads_ptr, + cli_credentials_get_password(self->cli_creds)); + if (self->ads_ptr->auth.password == NULL) { + PyErr_NoMemory(); + goto err; + } self->ads_ptr->auth.realm = talloc_strdup(self->ads_ptr, cli_credentials_get_realm(self->cli_creds)); if (self->ads_ptr->auth.realm == NULL) { @@ -254,22 +258,29 @@ static PyObject* py_ads_connect(ADS *self, goto err; } - passwd = secrets_fetch_machine_password(self->ads_ptr->server.workgroup, - NULL, NULL); + ret = asprintf(&(self->ads_ptr->auth.user_name), "%s$", + lp_netbios_name()); + if (ret == -1) { + PyErr_NoMemory(); + goto err; + } + + passwd = secrets_fetch_machine_password( + self->ads_ptr->server.workgroup, NULL, NULL); if (passwd == NULL) { PyErr_SetString(PyExc_RuntimeError, "Failed to fetch the machine account " "password"); goto err; } - ret = asprintf(&(self->ads_ptr->auth.user_name), "%s$", - lp_netbios_name()); - if (ret == -1) { - SAFE_FREE(passwd); + + self->ads_ptr->auth.password = talloc_strdup(self->ads_ptr, + passwd); + SAFE_FREE(passwd); + if (self->ads_ptr->auth.password == NULL) { PyErr_NoMemory(); goto err; } - self->ads_ptr->auth.password = passwd; /* take ownership of this data */ self->ads_ptr->auth.realm = talloc_asprintf_strupper_m( self->ads_ptr, "%s", self->ads_ptr->server.realm); if (self->ads_ptr->auth.realm == NULL) { |