From 710f6eb25222432e796394329a0497414a68816e Mon Sep 17 00:00:00 2001 From: Cafe137 <77121044+Cafe137@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:07:03 +0200 Subject: [PATCH] fix: throw error for too long tar entry (#968) * fix: throw error for too long tar entry * fix: throw error for too long tar entry --- src/utils/tar.browser.ts | 3 +++ src/utils/tar.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/utils/tar.browser.ts b/src/utils/tar.browser.ts index d7c2d57e..9234095e 100644 --- a/src/utils/tar.browser.ts +++ b/src/utils/tar.browser.ts @@ -13,6 +13,9 @@ export class TarStream { } beginFile(path: string, size: number) { + if (path.length > 100) { + throw new Error(`File name too long: ${path}`) + } const header = createHeader(path, size) this.pieces.push(header) this.currentFileSize = 0 diff --git a/src/utils/tar.ts b/src/utils/tar.ts index 4602b4cf..de9165d4 100644 --- a/src/utils/tar.ts +++ b/src/utils/tar.ts @@ -5,6 +5,9 @@ export class TarStream { currentFileSize = 0 beginFile(path: string, size: number) { + if (path.length > 100) { + throw new Error(`File name too long: ${path}`) + } const header = createHeader(path, size) this.output.write(header) this.currentFileSize = 0