Skip to content

Commit

Permalink
Merge pull request from GHSA-5jfw-35xp-5m42
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Apr 1, 2022
1 parent a6ccf86 commit d1f1afd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/LoginPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ protected function decodePayload(PacketSerializer $in) : void{
protected function decodeConnectionRequest(string $binary) : void{
$connRequestReader = new BinaryStream($binary);

$chainDataJson = json_decode($connRequestReader->get($connRequestReader->getLInt()));
$chainDataJsonLength = $connRequestReader->getLInt();
if($chainDataJsonLength <= 0){
//technically this is always positive; the problem results because getLInt() is implicitly signed
//this is inconsistent with many other methods, but we can't do anything about that for now
throw new PacketDecodeException("Length of chain data JSON must be positive");
}
$chainDataJson = json_decode($connRequestReader->get($chainDataJsonLength));
if(!is_object($chainDataJson)){
throw new PacketDecodeException("Failed decoding chain data JSON: " . json_last_error_msg());
}
Expand All @@ -68,7 +74,13 @@ protected function decodeConnectionRequest(string $binary) : void{
}

$this->chainDataJwt = $chainData;
$this->clientDataJwt = $connRequestReader->get($connRequestReader->getLInt());
$clientDataJwtLength = $connRequestReader->getLInt();
if($clientDataJwtLength <= 0){
//technically this is always positive; the problem results because getLInt() is implicitly signed
//this is inconsistent with many other methods, but we can't do anything about that for now
throw new PacketDecodeException("Length of clientData JWT must be positive");
}
$this->clientDataJwt = $connRequestReader->get($clientDataJwtLength);
}

protected function encodePayload(PacketSerializer $out) : void{
Expand Down

0 comments on commit d1f1afd

Please sign in to comment.