Adding to .zip archive removes file system access rules
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Iniziare in src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs, nel codice di finalizzazione intorno alle righe 3132-3143 e nella gestione dell’output temporaneo e finale intorno alle righe 4663-4713. Riprodurre il problema con il test fornito AddEntryRevertingFilePermissions, quindi aggiungere una copertura di regressione che dimostri che una regola di accesso sull’archivio rimane dopo CommitUpdate().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- 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");
}
- Break in the middle and amend permissions to the file by adding an access rule.
- 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)
- Compiled from source, commit: https://github.com/icsharpcode/SharpZipLib/commit/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1
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
- Lingua principale
- C#
- Stelle
- 3.9k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/SharpZipLib
-
*no response* bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
icsharpcode/SharpZipLib#905 · 1 commento ·
-
bug bzip2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFileApertaenhancement zip
Difficoltà 2/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
icsharpcode/SharpZipLib#901 · 1 commento ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
icsharpcode/SharpZipLib#894 · 1 commento ·
Tutte le issue di icsharpcode/SharpZipLib
Issue simili
-
ci-failure-cause test-failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
area:frontend bug FE hotspot:css mvp P3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
klasolsson81/jobbliggaren#1856 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: App+Library Build
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Aaronontheweb/freshdesk-cli#148 ·