Skip to content

Commit f07dc04

Browse files
authored
Fix
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 4ffd189 commit f07dc04

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/Updater.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,17 +744,20 @@ public function verifyIntegrity(): void {
744744
throw new \Exception('Failed to open downloaded file for integrity check');
745745
}
746746

747-
$hash = hash_init('sha512');
747+
$data = '';
748748
while (!feof($fh)) {
749749
$chunk = fread($fh, 8192);
750-
hash_update($hash, $chunk);
750+
if ($chunk === false) {
751+
fclose($fh);
752+
throw new \Exception('Error reading file during integrity check');
753+
}
754+
$data .= $chunk;
751755
}
752756
fclose($fh);
753-
$fileHash = hash_final($hash, true);
754757

755758
$signature = base64_decode($response['signature']);
756759

757-
$validSignature = openssl_verify($fileHash, $signature, $certificate, OPENSSL_ALGO_SHA512);
760+
$validSignature = openssl_verify($data, $signature, $certificate, OPENSSL_ALGO_SHA512);
758761
if ($validSignature !== 1) {
759762
throw new \Exception('Signature of update is not valid');
760763
}

0 commit comments

Comments
 (0)