Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Adding to .zip archive removes file system access rules

オープン
#654 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
backend

調査の方向性

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs の 3132-3143 行付近にあるファイナライズ処理と、4663-4713 行付近にある一時出力および最終出力の処理から始めてください。付属の AddEntryRevertingFilePermissions テストで問題を再現し、CommitUpdate() の後もアーカイブ上のアクセス規則が残ることを示す回帰テストカバレッジを追加してください。

索引モデルが issue の本文から書いたものです。

説明

When adding to a .zip archive on disk, the update does not happen in place. Instead, a temporary .zip file with the updated contents is created in a temporary directory first, which replaces the original archive after a successful write. As a result, any file system access rules set on the .zip archive that is updated are lost.

Steps to reproduce
  1. Run the snippet below in a debugger
		[Test]
		[Category("Zip")]
		[Category("CreatesTempFile")]
		public void AddEntryRevertingFilePermissions()
		{
			const string TestValue = "0001000";
			string tempFile = "c:/temp/";
			Assert.IsNotNull(tempFile, "No permission to execute this test?");

			tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");

			// create empty zip file
			using (ZipFile f = ZipFile.Create(tempFile))
			{
				f.BeginUpdate();
				f.CommitUpdate();
			}

			Console.WriteLine("break here and manually amend permissions for c:/temp/SharpZipTest.Zip by adding a rule");

			using (ZipFile f = new ZipFile(tempFile))
			{
				var m = new StringMemoryDataSource(TestValue);
				f.BeginUpdate();
				f.Add(m, "a.dat");
				f.CommitUpdate();
			}

			Console.WriteLine("permissions for c:/temp/SharpZipTest.Zip are reverted");
		}
  1. Break in the middle and amend permissions to the file by adding an access rule.
  2. Run to completion and verify that the file permission has reverted.
Expected behavior

File permissions should be retained

Actual behavior

File permissions inherited from temporary directory (e.g. C:\Users\username\AppData\Local\Temp\) are set

Version of SharpZipLib
Obtained from (only keep the relevant lines)
Further detail

The update is finalised: (directUpdate is false)
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L3132-L3143

The temporary output (pointing to a temporary directory ) is created at https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4663-L4669

The final output is created at
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4676-L4713

主要言語
C#
スター
3.9k
フォーク
1k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/SharpZipLib のほかの issue

icsharpcode/SharpZipLib の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。