Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect integrity of transformed files? #277

Open
toyobayashi opened this issue Aug 9, 2023 · 2 comments
Open

Incorrect integrity of transformed files? #277

toyobayashi opened this issue Aug 9, 2023 · 2 comments
Labels

Comments

@toyobayashi
Copy link
Contributor

asar/lib/filesystem.js

Lines 70 to 94 in c2b4777

const transformed = options.transform && options.transform(p)
if (transformed) {
const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), 'asar-'))
const tmpfile = path.join(tmpdir, path.basename(p))
const out = fs.createWriteStream(tmpfile)
const readStream = fs.createReadStream(p)
await pipeline(readStream, transformed, out)
file.transformed = {
path: tmpfile,
stat: await fs.lstat(tmpfile)
}
size = file.transformed.stat.size
} else {
size = file.stat.size
}
// JavaScript cannot precisely present integers >= UINT32_MAX.
if (size > UINT32_MAX) {
throw new Error(`${p}: file size can not be larger than 4.2GB`)
}
node.size = size
node.offset = this.offset.toString()
node.integrity = await getFileIntegrity(p)

node.integrity = await getFileIntegrity(p)

p is original file path, while transformed file path is

const tmpfile = path.join(tmpdir, path.basename(p))

@erikian
Copy link
Member

erikian commented Oct 21, 2023

I'm not sure if I understand the problem, could you elaborate?

@toyobayashi
Copy link
Contributor Author

@erikian Sorry for unclear context. I mean, code above shows that the integrity is computed for original file, not for transformed file. If transform options is provided, should it compute transformed file integrity to the node.integrity? Am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants