diff options
author | João Matos <joao@tritao.eu> | 2015-06-16 21:26:16 +0300 |
---|---|---|
committer | João Matos <joao@tritao.eu> | 2015-06-16 21:28:21 +0300 |
commit | 0d5437fc329d30271e5da18bc512cb7481a92523 (patch) | |
tree | 714e8df12b73ab9dfcbce7f5508c50439ab6ed02 /mcs/class/WindowsBase | |
parent | ba1a8099800613589a62c8e9c2c9d8c534886d79 (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.cs | 9 |
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; |