Skip to content

Commit

Permalink
fix possible server crash due to unlimited queue with packets, that c…
Browse files Browse the repository at this point in the history
…lient can't receive
  • Loading branch information
HarpyWar committed Aug 7, 2014
1 parent f62b7f4 commit 7863591
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bnetd/connection.cpp
Expand Up @@ -2277,6 +2277,16 @@ namespace pvpgn
return -1;
}

// Protection from hack attempt
// Limit out queue packets due to it may cause memory leak with not enough memory program crash on a server machine
t_queue ** q = &c->protocol.queues.outqueue;
if (queue_get_length((t_queue const * const *)q) > 1000)
{
queue_clear(q);
conn_set_state(c, conn_state_destroy);
return 0;
}

queue_push_packet((t_queue * *)&c->protocol.queues.outqueue, packet);
if (!c->protocol.queues.outsizep++) fdwatch_update_fd(c->socket.fdw_idx, fdwatch_type_read | fdwatch_type_write);

Expand Down

0 comments on commit 7863591

Please sign in to comment.