The branch, master has been updated via 0dd1c65 tevent: Add overflow protection to tevent_req_create via 8e989a1 tevent: Save 140 bytes of .text in tevent_req_create via 4110d73 tevent: Save 32 bytes of .text in tevent_req_create from 281b73f build: Add hints on what libraries to install for gpgme support on failure
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 0dd1c658c76ab24095ca591aa6e5a85ed59ff5f8 Author: Volker Lendecke <v...@samba.org> Date: Fri Jul 22 16:12:25 2016 +0200 tevent: Add overflow protection to tevent_req_create This adds 40 bytes, but they are needed for correctness :-) Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Fri Jul 22 23:33:57 CEST 2016 on sn-devel-144 commit 8e989a1afbdb024ae9200d89f18a5b107b181a98 Author: Volker Lendecke <v...@samba.org> Date: Fri Jul 22 16:06:45 2016 +0200 tevent: Save 140 bytes of .text in tevent_req_create This is one of or hottest code paths, I think every bit counts here. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 4110d73c3c53ca5cf87e3a34dc65d1835a49b57d Author: Volker Lendecke <v...@samba.org> Date: Fri Jul 22 16:06:45 2016 +0200 tevent: Save 32 bytes of .text in tevent_req_create This is one of or hottest code paths, I think every bit counts here. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/tevent/tevent_req.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c index c86fb68..e2b7104 100644 --- a/lib/tevent/tevent_req.c +++ b/lib/tevent/tevent_req.c @@ -62,6 +62,13 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx, struct tevent_req *req; void **ppdata = (void **)pdata; void *data; + size_t payload; + + payload = sizeof(struct tevent_immediate) + data_size; + if (payload < sizeof(struct tevent_immediate)) { + /* overflow */ + return NULL; + } req = talloc_pooled_object( mem_ctx, struct tevent_req, 2, @@ -69,21 +76,22 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } - ZERO_STRUCTP(req); - req->internal.private_type = type; - req->internal.create_location = location; - req->internal.state = TEVENT_REQ_IN_PROGRESS; - req->internal.trigger = tevent_create_immediate(req); - if (!req->internal.trigger) { - talloc_free(req); - return NULL; - } + + *req = (struct tevent_req) { + .internal.private_type = type, + .internal.create_location = location, + .internal.state = TEVENT_REQ_IN_PROGRESS, + .internal.trigger = tevent_create_immediate(req) + }; data = talloc_zero_size(req, data_size); - if (data == NULL) { - talloc_free(req); - return NULL; - } + + /* + * No need to check for req->internal.trigger!=NULL or + * data!=NULL, this can't fail: talloc_pooled_object has + * already allocated sufficient memory. + */ + talloc_set_name_const(data, type); req->data = data; -- Samba Shared Repository