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 d1547ee3b0
commit ba7cc279e6
No known key found for this signature in database
GPG key ID: FE03C3A163FEDE68

View file

@ -99,7 +99,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");
}
}