From 9bb422f9b2f55468ec1830da96bd08388e69c898 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Fri, 6 Mar 2026 09:51:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B3=B4=EC=95=88=20=EA=B0=95=ED=99=94?= =?UTF-8?q?=20=EB=B0=8F=20=EC=95=88=EC=A0=95=EC=84=B1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - extractZip: io.LimitReader 적용으로 zip bomb 방어 (개별 파일 4GB 제한) - moveContents: cross-drive 복사 실패 시 부분 파일 제거 Co-Authored-By: Claude Sonnet 4.6 --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 692622c..bf822af 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ const ( ) const maxDownloadSize = 2 << 30 // 2GB +const maxExtractFileSize = 4 << 30 // 개별 파일 최대 4GB var checkRedirect = func(req *http.Request, via []*http.Request) error { if req.URL.Scheme != "https" && req.URL.Scheme != "http" { @@ -559,7 +560,7 @@ func extractZip(zipPath, destDir string) error { rc.Close() return err } - _, err = io.Copy(out, rc) + _, err = io.Copy(out, io.LimitReader(rc, maxExtractFileSize)) out.Close() rc.Close() if err != nil { @@ -589,6 +590,7 @@ func moveContents(srcDir, dstDir string) error { if err := os.Rename(src, dst); err != nil { // 드라이브가 다를 경우 복사 후 삭제 if err := copyFile(src, dst); err != nil { + os.Remove(dst) // 실패한 부분 파일 제거 return err } }