cvs: pear /Net_GameServerQuery/GameServerQuery/Protocol HalfLife.php

From: Date: Fri, 21 Jan 2005 08:55:36 +0000
Subject: cvs: pear /Net_GameServerQuery/GameServerQuery/Protocol HalfLife.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-28722@lists.php.net to get a copy of this message
aidan Fri Jan 21 03:55:36 2005 EDT Modified files: /pear/Net_GameServerQuery/GameServerQuery/Protocol HalfLife.php Log: Check packet length before trying to peice it together (fixed bug in malformed queries) http://cvs.php.net/diff.php/pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php?r1=1.23&r2=1.24&ty=u Index: pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php diff -u pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php:1.23 pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php:1.24 --- pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php:1.23 Mon Jan 17 23:59:51 2005 +++ pear/Net_GameServerQuery/GameServerQuery/Protocol/HalfLife.php Fri Jan 21 03:55:36 2005 @@ -16,7 +16,7 @@ // | Tom Buskens <ortega@php.net> | // +----------------------------------------------------------------------+ // -// $Id: HalfLife.php,v 1.23 2005/01/18 04:59:51 aidan Exp $ +// $Id: HalfLife.php,v 1.24 2005/01/21 08:55:36 aidan Exp $ require_once NET_GAMESERVERQUERY_BASE . 'Protocol.php'; @@ -29,7 +29,7 @@ * @package Net_GameServerQuery * @author Aidan Lister <aidan@php.net> * @author Tom Buskens <ortega@php.net> - * @version $Revision: 1.23 $ + * @version $Revision: 1.24 $ */ class Net_GameServerQuery_Protocol_HalfLife extends Net_GameServerQuery_Protocol { @@ -50,10 +50,10 @@ return false; } - if ($buffer->readLast() !== "\x0") { + if ($buffer->readLast() !== "\x00") { return false; } - + while (!$buffer->is_empty()) { $result->add($buffer->readString('\\'), $buffer->readString('\\')); } @@ -118,6 +118,11 @@ { $result = array(); foreach ($packets as $packet) { + // Make sure it's a valid packet + if (strlen($packet) < 9) { + continue; + } + // Get the low nibble of the 9th bit $key = substr(bin2hex($packet{8}), 0, 1);

« previous php.pear.cvs (#28722) next »