Bug 361 - minizip as used by System.IO.Packaging is not 64bit safe
Summary: minizip as used by System.IO.Packaging is not 64bit safe
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WindowsBase (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-08-22 12:18 UTC by Alan McGovern
Modified: 2014-02-12 17:25 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Alan McGovern 2011-08-22 12:18:29 UTC
The minizip API exposes 'long' and 'ulong' types which are not fixed width. Therefore it's impossible to bind and P/Invoke these in a cross platform way. Currently we only work on systems where sizeof (IntPtr) == sizeof (native long).

First: Should we fix this?
    - Yes, ideally we should. If we don't fix it, maybe there should be a compile time make check to ensure sizeof (native long) == sizeof (native pointer).
Second: How should we fix it
    - We can expose a nicer API which uses fixed width types.
    - Or we can modify the existing minizip APIs to expose only fixed width sizes

The former is the least invasive but would make it confusing for people P/Invoking the native libs as there'd be two sets of APIs to choose from.

The latter would be better as there'd be a single set of working APIs which can be P/Invoked. However if we wanted to import a newer minizip we'd have a maintenance burden porting the changes to the newer minizip. Also we'd have to port every single usage of minizip in one go if we wanted to go with this approach. If it's P/Invoked elsewhere it'd just blow up as the existing P/Invoke declarations would no longer be compatible.
Comment 1 Miguel de Icaza [MSFT] 2014-02-12 17:25:23 UTC
I suggest that we force uLong (the only long I could find on the API) to be 32bits on 64 bit systems.

It seems that the code in minizip assumes that uLong is actually 32 bits in a few places.

Note You need to log in before you can comment on or make changes to this bug.