Skip to content

Commit

Permalink
Fix unpacking zero byte files from NPM (#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding authored Aug 30, 2023
1 parent 094bcca commit 690d621
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/snaps-controllers/src/snaps/location/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ describe('NpmLocation', () => {
const manifest = await location.manifest();
const sourceCode = (
await location.fetch(manifest.result.source.location.npm.filePath)
).value.toString();
).toString();
assert(manifest.result.source.location.npm.iconPath);
const svgIcon = (
await location.fetch(manifest.result.source.location.npm.iconPath)
).value.toString();
).toString();

expect(fetchMock).toHaveBeenCalledTimes(2);
expect(fetchMock).toHaveBeenNthCalledWith(
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/src/snaps/location/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function createTarballStream(
// The name is a path if the header type is "file".
const path = headerName.replace(NPM_TARBALL_PATH_PREFIX, '');
return entryStream.pipe(
concat((data) => {
concat({ encoding: 'uint8array' }, (data) => {
try {
totalSize += data.byteLength;
// To prevent zip bombs, we set a safety limit for the total size of tarballs.
Expand Down

0 comments on commit 690d621

Please sign in to comment.