diff options
author | Jeremy Allison <jra@samba.org> | 2007-04-30 02:39:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:49 -0500 |
commit | be8b0685a55700c6bce3681734800ec6434b0364 (patch) | |
tree | 8616d85686fb147d431eeea435233f45d5ee8d41 /source3/libmsrpc/cac_samr.c | |
parent | 79de0ad9463a5cd64978beae37df79fbb4f74632 (diff) | |
download | samba-be8b0685a55700c6bce3681734800ec6434b0364.tar.gz samba-be8b0685a55700c6bce3681734800ec6434b0364.tar.bz2 samba-be8b0685a55700c6bce3681734800ec6434b0364.zip |
r22589: Make TALLOC_ARRAY consistent across all uses.
Jeremy.
(This used to be commit 8968808c3b5b0208cbad9ac92eaf948f2c546dd9)
Diffstat (limited to 'source3/libmsrpc/cac_samr.c')
-rw-r--r-- | source3/libmsrpc/cac_samr.c | 140 |
1 files changed, 82 insertions, 58 deletions
diff --git a/source3/libmsrpc/cac_samr.c b/source3/libmsrpc/cac_samr.c index e50fb474f5..4d3acc85e3 100644 --- a/source3/libmsrpc/cac_samr.c +++ b/source3/libmsrpc/cac_samr.c @@ -557,10 +557,14 @@ int cac_SamGetNamesFromRids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx, && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) ) return CAC_FAILURE; - map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_names_out ); - if ( !map_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - return CAC_FAILURE; + if (num_names_out) { + map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_names_out ); + if ( !map_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + return CAC_FAILURE; + } + } else { + map_out = NULL; } for ( i = 0; i < num_names_out; i++ ) { @@ -643,10 +647,14 @@ int cac_SamGetRidsFromNames( CacServerHandle * hnd, TALLOC_CTX * mem_ctx, && !NT_STATUS_EQUAL( hnd->status, STATUS_SOME_UNMAPPED ) ) return CAC_FAILURE; - map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_rids_out ); - if ( !map_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - return CAC_FAILURE; + if (num_rids_out) { + map_out = TALLOC_ARRAY( mem_ctx, CacLookupRidsRecord, num_rids_out ); + if ( !map_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + return CAC_FAILURE; + } + } else { + map_out = NULL; } for ( i = 0; i < num_rids_out; i++ ) { @@ -718,16 +726,20 @@ int cac_SamGetGroupsForUser( CacServerHandle * hnd, TALLOC_CTX * mem_ctx, return CAC_FAILURE; - rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); - if ( !rids_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - return CAC_FAILURE; - } - - attr_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); - if ( !attr_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - return CAC_FAILURE; + if (num_groups_out) { + rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); + if ( !rids_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + return CAC_FAILURE; + } + attr_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); + if ( !attr_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + return CAC_FAILURE; + } + } else { + rids_out = NULL; + attr_out = NULL; } for ( i = 0; i < num_groups_out; i++ ) { @@ -1153,28 +1165,34 @@ int cac_SamEnumGroups( CacServerHandle * hnd, TALLOC_CTX * mem_ctx, return CAC_FAILURE; } - names_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out ); - if ( !names_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - return CAC_FAILURE; - } + if (num_groups_out) { + names_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out ); + if ( !names_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + return CAC_FAILURE; + } - desc_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out ); - if ( !desc_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - TALLOC_FREE( names_out ); - return CAC_FAILURE; - } + desc_out = TALLOC_ARRAY( mem_ctx, char *, num_groups_out ); + if ( !desc_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + TALLOC_FREE( names_out ); + return CAC_FAILURE; + } - rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); - if ( !rids_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - TALLOC_FREE( names_out ); - TALLOC_FREE( desc_out ); - return CAC_FAILURE; + rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_groups_out ); + if ( !rids_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + TALLOC_FREE( names_out ); + TALLOC_FREE( desc_out ); + return CAC_FAILURE; + } + } else { + names_out = NULL; + desc_out = NULL; + rids_out = NULL; } for ( i = 0; i < num_groups_out; i++ ) { @@ -1256,28 +1274,34 @@ int cac_SamEnumAliases( CacServerHandle * hnd, TALLOC_CTX * mem_ctx, NT_STATUS_V( STATUS_MORE_ENTRIES ) ) return CAC_FAILURE; - names_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out ); - if ( !names_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - return CAC_FAILURE; - } + if (num_als_out) { + names_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out ); + if ( !names_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + return CAC_FAILURE; + } - desc_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out ); - if ( !desc_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - TALLOC_FREE( names_out ); - return CAC_FAILURE; - } + desc_out = TALLOC_ARRAY( mem_ctx, char *, num_als_out ); + if ( !desc_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + TALLOC_FREE( names_out ); + return CAC_FAILURE; + } - rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_als_out ); - if ( !rids_out ) { - hnd->status = NT_STATUS_NO_MEMORY; - TALLOC_FREE( acct_buf ); - TALLOC_FREE( names_out ); - TALLOC_FREE( desc_out ); - return CAC_FAILURE; + rids_out = TALLOC_ARRAY( mem_ctx, uint32, num_als_out ); + if ( !rids_out ) { + hnd->status = NT_STATUS_NO_MEMORY; + TALLOC_FREE( acct_buf ); + TALLOC_FREE( names_out ); + TALLOC_FREE( desc_out ); + return CAC_FAILURE; + } + } else { + names_out = NULL; + desc_out = NULL; + rids_out = NULL; } for ( i = 0; i < num_als_out; i++ ) { |