Skip to content

Commit cad47b4

Browse files
Merge pull request #20 from AngelsSoftwareOrg/angelsburger90_development
Fix error when there's a repeated add of an entry due to directory traversal
2 parents 0c0a164 + a825aec commit cad47b4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.vs/OneClickZip/v16/.suo

11 KB
Binary file not shown.

Includes/Classes/ZipArchiving.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ private void StartCrawling()
139139
}
140140
}
141141
}
142-
catch (Exception)
142+
catch (Exception e)
143143
{
144+
#if DEBUG
145+
Console.WriteLine(e);
146+
#endif
144147
StopProcessingRaiseEvent();
145148
}
146149
}
@@ -154,7 +157,8 @@ private bool AddFileIntoZipArchive(ZipFile archiveFile, CustomFileItem customFil
154157
FileSystemUtilities.SanitizeFileName(customFileItem.GetCustomFileName));
155158
try
156159
{
157-
archiveFile.AddEntry(customFileName, File.OpenRead(customFileItem.FilePathFull));
160+
if(!archiveFile.ContainsEntry(customFileName))
161+
archiveFile.AddEntry(customFileName, File.OpenRead(customFileItem.FilePathFull));
158162

159163
//if there's a difference of, e.g. 50MB processed file size, then flush
160164
if ((processedZipFileSize - processedFilesSizeFlusherCtr) >= processedFilesSizeFlusherThreshold)
@@ -191,7 +195,7 @@ private void CrawlTreeStructure(SerializableTreeNode serializableTreeNode, ZipFi
191195
{
192196
IncrementFolderProcessedCountArgs();
193197
String newFolderName = String.Format("{0}{1}/", zipFileFolderName, customFile.GetCustomFileName);
194-
archiveFile.AddDirectoryByName(newFolderName);
198+
if (!archiveFile.ContainsEntry(newFolderName)) archiveFile.AddDirectoryByName(newFolderName);
195199
UpdateStatusAndRaiseEventProgressStatus(ZipProcessingStages.ADDING_FOLDER, customFile, newFolderName);
196200
}
197201
Application.DoEvents();

0 commit comments

Comments
 (0)