CVE-2015-5370: s4:librpc/rpc: protect dcerpc_request_recv_data() against too large...
authorStefan Metzmacher <metze@samba.org>
Fri, 10 Jul 2015 12:08:46 +0000 (14:08 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 30 Mar 2016 02:10:07 +0000 (04:10 +0200)
We should only allow a combined payload of a response of at max 4 MBytes.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11344

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source4/librpc/rpc/dcerpc.c

index 3a6dc571e19cf877cf358ac82b3180b23cd38b38..7b9777f267ac7c6bed2a34c8fa793f9fbcf2365d 100644 (file)
@@ -1567,6 +1567,15 @@ static void dcerpc_request_recv_data(struct dcecli_connection *c,
 
        length = pkt->u.response.stub_and_verifier.length;
 
+       if (req->payload.length + length > DCERPC_NCACN_PAYLOAD_MAX_SIZE) {
+               DEBUG(2,("Unexpected total payload 0x%X > 0x%X dcerpc response\n",
+                        (unsigned)req->payload.length + length,
+                        DCERPC_NCACN_PAYLOAD_MAX_SIZE));
+               req->fault_code = DCERPC_FAULT_OTHER;
+               req->status = NT_STATUS_NET_WRITE_FAULT;
+               goto req_done;
+       }
+
        if (length > 0) {
                req->payload.data = talloc_realloc(req, 
                                                   req->payload.data,