1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

r18879: Fix crash for "net ads gpo list".

Guenther
(This used to be commit 7df5808d8b)
This commit is contained in:
Günther Deschner 2006-09-24 23:44:00 +00:00 committed by Gerald (Jerry) Carter
parent 611b5d29fc
commit 82bf0da9d3
2 changed files with 14 additions and 10 deletions

View File

@ -380,12 +380,10 @@ ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
gpo->ds_path = ads_get_dn(ads, res); gpo->ds_path = ads_get_dn(ads, res);
} }
if (gpo->ds_path == NULL) { if (gpo->ds_path == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
if (!ads_pull_uint32(ads, res, "versionNumber", &gpo->version)) { if (!ads_pull_uint32(ads, res, "versionNumber", &gpo->version)) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
@ -395,25 +393,21 @@ ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
/* sure ??? */ /* sure ??? */
if (!ads_pull_uint32(ads, res, "flags", &gpo->options)) { if (!ads_pull_uint32(ads, res, "flags", &gpo->options)) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
gpo->file_sys_path = ads_pull_string(ads, mem_ctx, res, "gPCFileSysPath"); gpo->file_sys_path = ads_pull_string(ads, mem_ctx, res, "gPCFileSysPath");
if (gpo->file_sys_path == NULL) { if (gpo->file_sys_path == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
gpo->display_name = ads_pull_string(ads, mem_ctx, res, "displayName"); gpo->display_name = ads_pull_string(ads, mem_ctx, res, "displayName");
if (gpo->display_name == NULL) { if (gpo->display_name == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
gpo->name = ads_pull_string(ads, mem_ctx, res, "name"); gpo->name = ads_pull_string(ads, mem_ctx, res, "name");
if (gpo->name == NULL) { if (gpo->name == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
@ -421,8 +415,6 @@ ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
gpo->machine_extensions = ads_pull_string(ads, mem_ctx, res, "gPCMachineExtensionNames"); gpo->machine_extensions = ads_pull_string(ads, mem_ctx, res, "gPCMachineExtensionNames");
gpo->user_extensions = ads_pull_string(ads, mem_ctx, res, "gPCUserExtensionNames"); gpo->user_extensions = ads_pull_string(ads, mem_ctx, res, "gPCUserExtensionNames");
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_SUCCESS); return ADS_ERROR(LDAP_SUCCESS);
} }
@ -478,16 +470,18 @@ ADS_STATUS ads_get_gpo(ADS_STRUCT *ads,
if (ads_count_replies(ads, res) != 1) { if (ads_count_replies(ads, res) != 1) {
DEBUG(10,("ads_get_gpo: no result\n")); DEBUG(10,("ads_get_gpo: no result\n"));
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_SUCH_OBJECT); return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
} }
dn = ads_get_dn(ads, res); dn = ads_get_dn(ads, res);
if (dn == NULL) { if (dn == NULL) {
ads_msgfree(ads, res);
return ADS_ERROR(LDAP_NO_MEMORY); return ADS_ERROR(LDAP_NO_MEMORY);
} }
status = ads_parse_gpo(ads, mem_ctx, res, dn, gpo); status = ads_parse_gpo(ads, mem_ctx, res, dn, gpo);
ads_msgfree(ads, res);
ads_memfree(ads, dn); ads_memfree(ads, dn);
return status; return status;

View File

@ -139,6 +139,16 @@ static int net_ads_gpo_list(int argc, const char **argv)
struct GROUP_POLICY_OBJECT gpo; struct GROUP_POLICY_OBJECT gpo;
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;
char *dn; char *dn;
const char *attrs[] = {
"versionNumber",
"flags",
"gPCFileSysPath",
"displayName",
"name",
"gPCMachineExtensionNames",
"gPCUserExtensionNames",
NULL
};
mem_ctx = talloc_init("net_ads_gpo_list"); mem_ctx = talloc_init("net_ads_gpo_list");
if (mem_ctx == NULL) { if (mem_ctx == NULL) {
@ -152,7 +162,7 @@ static int net_ads_gpo_list(int argc, const char **argv)
status = ads_do_search_all(ads, ads->config.bind_path, status = ads_do_search_all(ads, ads->config.bind_path,
LDAP_SCOPE_SUBTREE, LDAP_SCOPE_SUBTREE,
"(objectclass=groupPolicyContainer)", NULL, &res); "(objectclass=groupPolicyContainer)", attrs, &res);
if (!ADS_ERR_OK(status)) { if (!ADS_ERR_OK(status)) {
d_printf("search failed: %s\n", ads_errstr(status)); d_printf("search failed: %s\n", ads_errstr(status));
goto out; goto out;