Fix integer overflow in ChunkingPlugin

Avoids errors when the size exceeds MAX_INT because of the cast to int. Better cast it to float to avoid this.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-01-30 14:22:31 +01:00
parent 846b0d6a42
commit fc4e0501f0
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
1 changed files with 4 additions and 1 deletions

View File

@ -97,7 +97,10 @@ class ChunkingPlugin extends ServerPlugin {
return;
}
$actualSize = $this->sourceNode->getSize();
if ((int)$expectedSize !== $actualSize) {
// casted to string because cast to float cause equality for non equal numbers
// and integer has the problem of limited size on 32 bit systems
if ((string)$expectedSize !== (string)$actualSize) {
throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes");
}
}