summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-05-08 22:04:28 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:16 -0500
commitda7f449a07a30cb03d744f155861a7e7318809d6 (patch)
tree11678ee941213d2582d6b88fe430f359cf0b911c
parentcc26fe9b749d00bc7c002f6a5a24ff67af497c49 (diff)
downloadsamba-da7f449a07a30cb03d744f155861a7e7318809d6.tar.gz
samba-da7f449a07a30cb03d744f155861a7e7318809d6.tar.bz2
samba-da7f449a07a30cb03d744f155861a7e7318809d6.zip
r22763: replace talloc_zero calls with composite_create and add more
allocation checks. rafal (This used to be commit 621f3e567478fc8067f08f3589b54bf58ca9e1f1)
-rw-r--r--source4/libnet/userinfo.c22
-rw-r--r--source4/libnet/userman.c11
2 files changed, 16 insertions, 17 deletions
diff --git a/source4/libnet/userinfo.c b/source4/libnet/userinfo.c
index 57a30e59dc..35fd2f33ba 100644
--- a/source4/libnet/userinfo.c
+++ b/source4/libnet/userinfo.c
@@ -262,24 +262,22 @@ struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p,
if (!p || !io) return NULL;
- c = talloc_zero(p, struct composite_context);
- if (c == NULL) goto failure;
+ c = composite_create(p, dcerpc_event_context(p));
+ if (c == NULL) return c;
s = talloc_zero(c, struct userinfo_state);
- if (s == NULL) goto failure;
+ if (composite_nomem(s, c)) return c;
+
+ c->private_data = s;
s->level = io->in.level;
s->pipe = p;
s->domain_handle = io->in.domain_handle;
s->monitor_fn = monitor;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->private_data = s;
- c->event_ctx = dcerpc_event_context(p);
-
if (io->in.sid) {
sid = dom_sid_parse_talloc(s, io->in.sid);
- if (sid == NULL) goto failure;
+ if (composite_nomem(sid, c)) return c;
s->openuser.in.domain_handle = &s->domain_handle;
s->openuser.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -288,7 +286,7 @@ struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p,
/* send request */
s->req = dcerpc_samr_OpenUser_send(p, c, &s->openuser);
- if (s->req == NULL) goto failure;
+ if (composite_nomem(s->req, c)) return c;
s->stage = USERINFO_OPENUSER;
@@ -303,7 +301,7 @@ struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p,
/* send request */
s->req = dcerpc_samr_LookupNames_send(p, c, &s->lookup);
- if (s->req == NULL) goto failure;
+ if (composite_nomem(s->req, c)) return c;
s->stage = USERINFO_LOOKUP;
}
@@ -313,10 +311,6 @@ struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p,
s->req->async.private = c;
return c;
-
-failure:
- talloc_free(c);
- return NULL;
}
diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c
index 13834d2842..879efe9176 100644
--- a/source4/libnet/userman.c
+++ b/source4/libnet/userman.c
@@ -127,16 +127,16 @@ struct composite_context *libnet_rpc_useradd_send(struct dcerpc_pipe *p,
struct composite_context *c;
struct useradd_state *s;
+ if (!p || !io) return NULL;
+
/* composite allocation and setup */
- c = talloc_zero(p, struct composite_context);
+ c = composite_create(p, dcerpc_event_context(p));
if (c == NULL) return NULL;
s = talloc_zero(c, struct useradd_state);
if (composite_nomem(s, c)) return c;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
c->private_data = s;
- c->event_ctx = dcerpc_event_context(p);
/* put passed arguments to the state structure */
s->domain_handle = io->in.domain_handle;
@@ -145,8 +145,13 @@ struct composite_context *libnet_rpc_useradd_send(struct dcerpc_pipe *p,
/* preparing parameters to send rpc request */
s->createuser.in.domain_handle = &io->in.domain_handle;
+
s->createuser.in.account_name = talloc_zero(c, struct lsa_String);
+ if (composite_nomem(s->createuser.in.account_name, c)) return c;
+
s->createuser.in.account_name->string = talloc_strdup(c, io->in.username);
+ if (composite_nomem(s->createuser.in.account_name->string, c)) return c;
+
s->createuser.out.user_handle = &s->user_handle;
s->createuser.out.rid = &s->user_rid;