diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-16 23:21:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:17:33 -0500 |
commit | d730df0493ee8135cc2315aab3ffb1a0d3b5660a (patch) | |
tree | e692f847de0b77099b729124bad23667dae54c41 /source3/libads | |
parent | be6fd7643659406b6df986e1a96f7e9b87abfe20 (diff) | |
download | samba-d730df0493ee8135cc2315aab3ffb1a0d3b5660a.tar.gz samba-d730df0493ee8135cc2315aab3ffb1a0d3b5660a.tar.bz2 samba-d730df0493ee8135cc2315aab3ffb1a0d3b5660a.zip |
r16324: Klocwork #499. Allways check results from alloc.
Jeremy.
(This used to be commit 2b69d436da7b2902ea419f3bcc45c7b5a5c571fb)
Diffstat (limited to 'source3/libads')
-rw-r--r-- | source3/libads/ldap.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index be15643ba2..13459ba40d 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -1430,16 +1430,28 @@ ADS_STATUS ads_add_service_principal_name(ADS_STRUCT *ads, const char *machine_n if (!(host_spn = talloc_asprintf(ctx, "HOST/%s", my_fqdn))) { talloc_destroy(ctx); ads_msgfree(ads, res); - return ADS_ERROR(LDAP_NO_SUCH_OBJECT); + return ADS_ERROR(LDAP_NO_MEMORY); } /* Add the extra principal */ psp1 = talloc_asprintf(ctx, "%s/%s", spn, machine_name); + if (!psp1) { + talloc_destroy(ctx); + ads_msgfree(ads, res); + return ADS_ERROR(LDAP_NO_MEMORY); + } + strupper_m(psp1); strlower_m(&psp1[strlen(spn)]); DEBUG(5,("ads_add_service_principal_name: INFO: Adding %s to host %s\n", psp1, machine_name)); servicePrincipalName[0] = psp1; psp2 = talloc_asprintf(ctx, "%s/%s.%s", spn, machine_name, ads->config.realm); + if (!psp2) { + talloc_destroy(ctx); + ads_msgfree(ads, res); + return ADS_ERROR(LDAP_NO_MEMORY); + } + strupper_m(psp2); strlower_m(&psp2[strlen(spn)]); DEBUG(5,("ads_add_service_principal_name: INFO: Adding %s to host %s\n", psp2, machine_name)); @@ -1449,6 +1461,12 @@ ADS_STATUS ads_add_service_principal_name(ADS_STRUCT *ads, const char *machine_n * the KDC doesn't send "server principal unknown" errors to clients * which use the DNS name in determining service principal names. */ psp3 = talloc_asprintf(ctx, "%s/%s", spn, my_fqdn); + if (!psp3) { + talloc_destroy(ctx); + ads_msgfree(ads, res); + return ADS_ERROR(LDAP_NO_MEMORY); + } + strupper_m(psp3); strlower_m(&psp3[strlen(spn)]); if (strcmp(psp2, psp3) != 0) { |