}
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 {
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;
#ifdef HAVE_LDAP
ads_disconnect(*ads);
#endif
- SAFE_FREE((*ads)->auth.realm);
SAFE_FREE((*ads)->auth.password);
SAFE_FREE((*ads)->auth.user_name);
SAFE_FREE((*ads)->auth.kdc_server);
}
}
- if (!ads->auth.realm) {
- ads->auth.realm = SMB_STRDUP(ads->config.realm);
+ if (ads->auth.realm == NULL) {
+ ads->auth.realm = talloc_strdup(ads, ads->config.realm);
+ if (ads->auth.realm == NULL) {
+ status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ goto out;
+ }
}
if (!ads->auth.kdc_server) {
my_ads->auth.user_name = SMB_STRDUP(user_name);
if ((cp = strchr_m(my_ads->auth.user_name, '@'))!=0) {
*cp++ = '\0';
- SAFE_FREE(my_ads->auth.realm);
- my_ads->auth.realm = smb_xstrdup(cp);
- if (!strupper_m(my_ads->auth.realm)) {
+ TALLOC_FREE(my_ads->auth.realm);
+ my_ads->auth.realm = talloc_asprintf_strupper_m(my_ads, "%s", cp);
+ if (my_ads->auth.realm == NULL) {
status = ADS_ERROR_LDAP(LDAP_NO_MEMORY);
goto out;
}
*/
if ((cp = strchr_m(ads->auth.user_name, '@'))!=0) {
*cp++ = '\0';
- SAFE_FREE(ads->auth.realm);
- ads->auth.realm = smb_xstrdup(cp);
- if (!strupper_m(ads->auth.realm)) {
+ TALLOC_FREE(ads->auth.realm);
+ ads->auth.realm = talloc_asprintf_strupper_m(ads, "%s", cp);
+ if (ads->auth.realm == NULL) {
TALLOC_FREE(ads);
return ADS_ERROR(LDAP_NO_MEMORY);
}
goto done;
}
- ads_dns->auth.realm = SMB_STRDUP(r->out.dns_domain_name);
+ ads_dns->auth.realm = talloc_asprintf_strupper_m(ads_dns, "%s", r->out.dns_domain_name);
if (ads_dns->auth.realm == NULL) {
- d_fprintf(stderr, _("DNS update failed: out of memory\n"));
- goto done;
- }
-
- if (!strupper_m(ads_dns->auth.realm)) {
- d_fprintf(stderr, _("strupper_m %s failed\n"), ads_dns->auth.realm);
+ d_fprintf(stderr, _("talloc_asprintf_strupper_m %s failed\n"),
+ ads_dns->auth.realm);
goto done;
}
}
SAFE_FREE(ads->auth.password);
- SAFE_FREE(ads->auth.realm);
+ TALLOC_FREE(ads->auth.realm);
ads->auth.renewable = renewable;
ads->auth.password = password;
break;
}
- ads->auth.realm = SMB_STRDUP(auth_realm);
- if (!strupper_m(ads->auth.realm)) {
+ ads->auth.realm = talloc_asprintf_strupper_m(ads, "%s", auth_realm);
+ if (ads->auth.realm == NULL) {
status = ADS_ERROR_NT(NT_STATUS_INTERNAL_ERROR);
goto out;
}