diff options
author | Samuel Cabrero <scabrero@suse.de> | 2022-06-13 12:38:24 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-06-27 15:50:30 +0000 |
commit | c1ab39163bbaf8ef9c8dc92b1d14c3f6cb56456c (patch) | |
tree | 03030aff52526c5c1ebea1b42275ceac6c0a682c /libgpo/pygpo.c | |
parent | cc8465f1b79e335d9af6a2c2edf128aa5ce07ec0 (diff) | |
download | samba-c1ab39163bbaf8ef9c8dc92b1d14c3f6cb56456c.tar.gz |
s3:libads: Allocate ads->auth.realm 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 | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index 710f7fa896d..85a4aaa1581 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -231,14 +231,18 @@ static PyObject* py_ads_connect(ADS *self, } SAFE_FREE(self->ads_ptr->auth.user_name); SAFE_FREE(self->ads_ptr->auth.password); - SAFE_FREE(self->ads_ptr->auth.realm); + 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.realm = - SMB_STRDUP(cli_credentials_get_realm(self->cli_creds)); + self->ads_ptr->auth.realm = talloc_strdup(self->ads_ptr, + cli_credentials_get_realm(self->cli_creds)); + if (self->ads_ptr->auth.realm == NULL) { + PyErr_NoMemory(); + goto err; + } self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; status = ads_connect_user_creds(self->ads_ptr); } else { @@ -266,10 +270,10 @@ static PyObject* py_ads_connect(ADS *self, goto err; } self->ads_ptr->auth.password = passwd; /* take ownership of this data */ - self->ads_ptr->auth.realm = - SMB_STRDUP(self->ads_ptr->server.realm); - if (!strupper_m(self->ads_ptr->auth.realm)) { - PyErr_SetString(PyExc_RuntimeError, "Failed to strupper"); + 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) { + PyErr_NoMemory(); goto err; } self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; |