Skip to content

Commit

Permalink
detection of oversized requests from clients
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 6, 2005
1 parent 51d0c8b commit 9824495
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mod/chat/chatd.php
Expand Up @@ -973,11 +973,17 @@ function cli_switch($switch, $param = NULL) {
if($changed > 0) { if($changed > 0) {
// Let's see what it has to say // Let's see what it has to say


$data = socket_read($handle, 2048); // should be more to prevent empty pages and repeated messages!! $data = socket_read($handle, 2048); // should be more than 512 to prevent empty pages and repeated messages!!
if(empty($data)) { if(empty($data)) {
continue; continue;
} }


if (strlen($data) == 2048) { // socket_read has more data, ignore all data
$DAEMON->trace('UFO with '.$handle.': Data too long; connection closed', E_USER_WARNING);
$DAEMON->dismiss_ufo($handle, true, 'Data too long; connection closed');
continue;
}

if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&groupid=([0-9]*) HTTP', $data, $info)) { if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&groupid=([0-9]*) HTTP', $data, $info)) {
// Malformed data // Malformed data
$DAEMON->trace('UFO with '.$handle.': Request with malformed data; connection closed', E_USER_WARNING); $DAEMON->trace('UFO with '.$handle.': Request with malformed data; connection closed', E_USER_WARNING);
Expand Down

0 comments on commit 9824495

Please sign in to comment.