Skip to content

Commit 0e772cf

Browse files
authored
Fix binary hash check (#58)
1 parent 121ae5d commit 0e772cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Service/UtilsService.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ public function compareBinaryHash(string $url, string $binaryPath) {
334334
$binaryData = file_get_contents($binaryPath);
335335
$currentBinaryHash = hash('sha256', $binaryData);
336336
$newBinaryHash = $this->downloadBinaryHash(str_replace('.gz', '.sha256', $url));
337-
if ($newBinaryHash['success'] && strlen($newBinaryHash['binaryHash']) == 64) {
338-
return $currentBinaryHash != $newBinaryHash['binaryHash'];
337+
$newHash = substr($newBinaryHash['binaryHash'], 0, 64);
338+
if ($newBinaryHash['success'] && strlen($newHash) == 64) {
339+
return $currentBinaryHash != $newHash;
339340
}
340341
}
341342
return true;
@@ -352,7 +353,8 @@ public function downloadBinaryHash(string $url): array {
352353
$cURL = curl_init($url);
353354
curl_setopt_array($cURL, [
354355
CURLOPT_RETURNTRANSFER => true,
355-
CURLOPT_RANGE => 64,
356+
CURLOPT_FOLLOWLOCATION => true,
357+
CURLOPT_RANGE => '0-64',
356358
]);
357359
$binaryHash = curl_exec($cURL);
358360
curl_close($cURL);

0 commit comments

Comments
 (0)