tevent: Add overflow protection to tevent_req_create
authorVolker Lendecke <vl@samba.org>
Fri, 22 Jul 2016 14:12:25 +0000 (16:12 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 22 Jul 2016 21:33:57 +0000 (23:33 +0200)
This adds 40 bytes, but they are needed for correctness :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Jul 22 23:33:57 CEST 2016 on sn-devel-144

lib/tevent/tevent_req.c

index fe613cc834ca152a93ff958cd2419ae67a56fd5b..e2b7104d16a2f3802b2b4013d1374dac9f2ebf6c 100644 (file)
@@ -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,