Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Matos <joao@tritao.eu>2015-06-16 21:26:16 +0300
committerJoão Matos <joao@tritao.eu>2015-06-16 21:28:21 +0300
commit0d5437fc329d30271e5da18bc512cb7481a92523 (patch)
tree714e8df12b73ab9dfcbce7f5508c50439ab6ed02 /mcs/class/WindowsBase
parentba1a8099800613589a62c8e9c2c9d8c534886d79 (diff)
[WindowsBase] Fixed string buffer overflow when handling Zip entries.
Fixes NuGet package handling, see https://bugzilla.xamarin.com/show_bug.cgi?id=26205.
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r--mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs9
1 files changed, 7 insertions, 2 deletions
diff --git a/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs b/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs
index 47e277bdbfb..79a9dc62aec 100644
--- a/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs
+++ b/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs
@@ -80,8 +80,13 @@ namespace zipsharp
static string GetCurrentFileName (UnzipHandle handle)
{
UnzipFileInfo info;
- StringBuilder sbName = new StringBuilder (128);
- int result = unzGetCurrentFileInfo (handle, out info, sbName, new IntPtr (sbName.Capacity), IntPtr.Zero, new IntPtr (0), null, IntPtr.Zero);
+ int result = unzGetCurrentFileInfo (handle, out info, null, IntPtr.Zero, IntPtr.Zero, new IntPtr (0), null, IntPtr.Zero);
+
+ if (result != 0)
+ return null;
+
+ StringBuilder sbName = new StringBuilder ((int)info.SizeFilename+1); // +1 to account for extra \0 at the end
+ result = unzGetCurrentFileInfo (handle, out info, sbName, new IntPtr (sbName.Capacity), IntPtr.Zero, new IntPtr (0), null, IntPtr.Zero);
if (result != 0)
return null;