Skip to content

Commit 9b5dd05

Browse files
committed
Check CEF for consistency after downloading
Revert to old method of computing hash (CertUtil) because escaping batch scripts is broken
1 parent cb5af3e commit 9b5dd05

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

utils/buildactions/install_cef.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ newaction {
105105
return
106106
end
107107

108+
local downloaded_hash = os.sha256_file(archive_path)
108109
if upgrade then
109-
local downloaded_hash = os.sha256_file(archive_path)
110110
print("New CEF hash is:", downloaded_hash)
111111
CEF_HASH = downloaded_hash
112112

@@ -117,6 +117,14 @@ newaction {
117117
end
118118
end
119119

120+
if downloaded_hash == CEF_HASH then
121+
print("CEF consistency checks succeeded")
122+
else
123+
errormsg("CEF consistency checks failed.", ("Expected %s, got %s"):format(CEF_HASH, downloaded_hash))
124+
os.exit(1)
125+
return
126+
end
127+
120128
-- Seriously abort now if we're not using Windows
121129
if os.host() ~= "windows" then
122130
return

utils/buildactions/utils.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,25 @@ function os.expanddir_wildcard(from, to)
8484
end
8585

8686
function os.sha256_file(path)
87+
local windows = os.host() == "windows"
8788
local s, errc
88-
if os.host() == "windows" then
89-
s, errc = os.outputof(string.format("powershell -Command (Get-FileHash \"%s\" -Algorithm SHA256).Hash", path))
89+
if windows then
90+
s, errc = os.outputof(string.format("CertUtil -hashfile \"%s\" SHA256", path))
9091
else
9192
s, errc = os.outputof(string.format("sha256sum \"%s\" | awk '{ print $1 }'", path))
9293
end
94+
95+
-- Check for error
9396
if errc ~= 0 then
9497
print("Error os.sha256_file: ", errc)
9598
return ""
9699
end
100+
101+
-- Clean windows output
102+
if windows then
103+
s = (s:match("\n(.*)\n(.*)") or ""):gsub(" ", "")
104+
end
105+
97106
return s:lower()
98107
end
99108

0 commit comments

Comments
 (0)