Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix or drop zipOpen2/unzOpen2 #566

Closed
berolinux opened this issue May 2, 2021 · 2 comments
Closed

fix or drop zipOpen2/unzOpen2 #566

berolinux opened this issue May 2, 2021 · 2 comments

Comments

@berolinux
Copy link

zipOpen2 and unzOpen2 currently cast a zlib_filefunc_def* to mz_stream_vtbl*
Since those structs contain different functions with different parameters in a different order, this will crash the calling application at best and corrupt data (unzOpen2 actually calling into a function that opens the file for writing) at worst.

The functions should either be implemented in a compatible way, or at least removed so users don't think this is going to work before actually running into something that calls the functions.

@nmoinvaz
Copy link
Member

nmoinvaz commented May 8, 2021

I have implemented the ioapi support. Only thing missing is wide-character ioapi support for Windows. If somebody really cares about that they can figure it out themselves.

@gvollant
Copy link
Collaborator

gvollant commented May 8, 2021

my very old code was


#ifdef IOWIN32_USING_WINRT_API
#ifdef UNICODE
    if ((filename!=NULL) && (dwDesiredAccess != 0))
        hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
#else
    if ((filename!=NULL) && (dwDesiredAccess != 0))
    {
        WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
        MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
        hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
    }
#endif
#else
    if ((filename!=NULL) && (dwDesiredAccess != 0))
        hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
#endif

If I remember, that was for WINRT which was not compatible with Ansi API....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants