s3: Limit the number of unexpected packets per client to 10
authorVolker Lendecke <vl@samba.org>
Wed, 5 Jan 2011 13:34:04 +0000 (14:34 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 7 Jan 2011 12:28:07 +0000 (13:28 +0100)
Non-reading clients could maliciously make nmbd allocate memory

source3/libsmb/unexpected.c

index ce1e31dc59feefd6da6e84a3072b78c46accb5f2..7ec5800e69af468be643cba8062e5201656f27d6 100644 (file)
@@ -672,6 +672,14 @@ static void nb_packet_client_send(struct nb_packet_client *client,
        struct nb_packet_client_state *state;
        struct tevent_req *req;
 
+       if (tevent_queue_length(client->out_queue) > 10) {
+               /*
+                * Skip clients that don't listen anyway, some form of DoS
+                * protection
+                */
+               return;
+       }
+
        state = TALLOC_ZERO_P(client, struct nb_packet_client_state);
        if (state == NULL) {
                DEBUG(10, ("talloc failed\n"));