summaryrefslogtreecommitdiff
path: root/source3/libmsrpc/cac_lsarpc.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-30 02:39:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:49 -0500
commitbe8b0685a55700c6bce3681734800ec6434b0364 (patch)
tree8616d85686fb147d431eeea435233f45d5ee8d41 /source3/libmsrpc/cac_lsarpc.c
parent79de0ad9463a5cd64978beae37df79fbb4f74632 (diff)
downloadsamba-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_lsarpc.c')
-rw-r--r--source3/libmsrpc/cac_lsarpc.c89
1 files changed, 56 insertions, 33 deletions
diff --git a/source3/libmsrpc/cac_lsarpc.c b/source3/libmsrpc/cac_lsarpc.c
index 2e3eb276d5..de53c0f483 100644
--- a/source3/libmsrpc/cac_lsarpc.c
+++ b/source3/libmsrpc/cac_lsarpc.c
@@ -203,11 +203,15 @@ int cac_LsaGetNamesFromSids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
if ( NT_STATUS_IS_OK( hnd->status ) ) {
/*this is the easy part, just make the out.sids array */
- sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_sids );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if (num_sids) {
+ sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_sids );
+ if ( !sids_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ sids_out = NULL;
}
for ( i = 0; i < num_sids; i++ ) {
@@ -232,22 +236,29 @@ int cac_LsaGetNamesFromSids( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
return CAC_FAILURE;
}
- sids_out =
- TALLOC_ARRAY( mem_ctx, CacSidInfo,
+ if ( num_sids - num_unknown) {
+ sids_out =
+ TALLOC_ARRAY( mem_ctx, CacSidInfo,
( num_sids - num_unknown ) );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if ( !sids_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ sids_out = NULL;
}
- unknown_out = TALLOC_ARRAY( mem_ctx, DOM_SID, num_unknown );
- if ( !unknown_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if (num_unknown) {
+ unknown_out = TALLOC_ARRAY( mem_ctx, DOM_SID, num_unknown );
+ if ( !unknown_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ unknown_out = NULL;
}
-
found_idx = unknown_idx = 0;
/*now we can actually do the real work */
@@ -330,11 +341,15 @@ int cac_LsaGetSidsFromNames( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
if ( NT_STATUS_IS_OK( hnd->status ) ) {
/*this is the easy part, just make the out.sids array */
- sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_names );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if (num_names) {
+ sids_out = TALLOC_ARRAY( mem_ctx, CacSidInfo, num_names );
+ if ( !sids_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ sids_out = NULL;
}
for ( i = 0; i < num_names; i++ ) {
@@ -360,20 +375,28 @@ int cac_LsaGetSidsFromNames( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
return CAC_FAILURE;
}
- sids_out =
- TALLOC_ARRAY( mem_ctx, CacSidInfo,
+ if (num_names - num_unknown) {
+ sids_out =
+ TALLOC_ARRAY( mem_ctx, CacSidInfo,
( num_names - num_unknown ) );
- if ( !sids_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if ( !sids_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ sids_out = NULL;
}
- unknown_out = TALLOC_ARRAY( mem_ctx, char *, num_unknown );
- if ( !unknown_out ) {
- errno = ENOMEM;
- hnd->status = NT_STATUS_NO_MEMORY;
- return CAC_FAILURE;
+ if (num_unknown) {
+ unknown_out = TALLOC_ARRAY( mem_ctx, char *, num_unknown );
+ if ( !unknown_out ) {
+ errno = ENOMEM;
+ hnd->status = NT_STATUS_NO_MEMORY;
+ return CAC_FAILURE;
+ }
+ } else {
+ unknown_out = NULL;
}
unknown_idx = found_idx = 0;