diff options
author | Rafal Szczesniak <mimir@samba.org> | 2007-05-08 22:04:28 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:52:16 -0500 |
commit | da7f449a07a30cb03d744f155861a7e7318809d6 (patch) | |
tree | 11678ee941213d2582d6b88fe430f359cf0b911c /source4 | |
parent | cc26fe9b749d00bc7c002f6a5a24ff67af497c49 (diff) | |
download | samba-da7f449a07a30cb03d744f155861a7e7318809d6.tar.gz samba-da7f449a07a30cb03d744f155861a7e7318809d6.tar.xz samba-da7f449a07a30cb03d744f155861a7e7318809d6.zip |
r22763: replace talloc_zero calls with composite_create and add more
allocation checks.
rafal
(This used to be commit 621f3e567478fc8067f08f3589b54bf58ca9e1f1)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libnet/userinfo.c | 22 | ||||
-rw-r--r-- | source4/libnet/userman.c | 11 |
2 files changed, 16 insertions, 17 deletions
diff --git a/source4/libnet/userinfo.c b/source4/libnet/userinfo.c index 57a30e59dc8..35fd2f33bac 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 13834d28423..879efe91761 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; |