Commit Graph

77 Commits

Author SHA1 Message Date
Nyq
90a5b2f89b
Prevent min/max conflicts between windows.h and std namespace
Miniz started including windows.h from version 3.0.0 and on when compiling for Windows using MSVC.

windows.h header file is known to conflict with C++ std namespace by defining its own min/max macros. It is a common practice to disable these ancient macros in windows.h by declaring NOMINMAX macro prior to including windows.h in code.

While this issue does not affect miniz directly due to the fact that it is straight-C code and it does not use min/max from C++ std namespace, it does affect other projects like miniz-cpp which wrap and amalgamate miniz and then both compile in C++ mode and use min/max from std namespace.

It is therefore proposed to prefix inclusion of windows.h in miniz_zip.c by the following lines:

#ifndef NOMINMAX
#define NOMINMAX
#endif
2023-08-15 07:21:03 -04:00
Nyq
fd55960854
Update miniz_zip.c to prevent compilation warning when compiling for Windows in straight C mode
Summary:
Added conditional macro definition to prevent MSVC compiler warning C5105 when compiling for Windows in straight C mode

Details:
Since version 3.0.0 miniz_zip.c includes windows.h header file when compiling for Windows using MSVC. However, when compiling miniz_zip.c using MSVC17 in straight-C mode (no C++), this inclusion causes warning C5105:

winbase.h(9531,5): warning C5105: macro expansion producing 'defined' has undefined behavior

This warning is not produced when compiling in C++ mode.

In order to prevent the warning, any straight-C code that wants to include windows.h should make an additional define before including:
#ifndef __cplusplus
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
#endif
#include <windows.h>
2023-08-15 05:39:55 -04:00
Martin Raiber
9ae305f6e1
Merge pull request #268 from jpcha2/master
Ensure correct integer promotion when adding
2023-04-12 21:10:11 +02:00
Jakob Gahde
654bf8bdeb
Fix Unicode paths on MinGW32 2023-02-14 07:10:06 +01:00
jpcha2
f0709ed3f5
Update miniz_zip.c
Code Quality (Avoid Integer Overflow): Ensure correct order of integer size promotion when doing additions by placing the mz_uint64 value first or explicitly casting the first value to mz_uint64.
2023-01-17 11:49:41 +03:00
jpcha2
78e9404362
Update miniz_zip.c
Bugfix: MultiByteToWideChar() is being called with a byte count instead of a character count. This will cause a buffer overrun.
2022-11-21 04:36:20 +03:00
Martin Raiber
92ab73ac32
Merge pull request #236 from Dialga/patch-1
Fix callback typo
2022-08-25 22:02:06 +02:00
Martin Raiber
4a8dc21d9d
Merge pull request #238 from kobrineli/fix-overflow
Fix integer overflow in header corruption check.
2022-08-25 21:58:37 +02:00
Dmitry Marakasov
de0a4d2444 Use stdio functions without 64 suffix on FreeBSD
FreeBSD neither has nor needs suffixed functions
2022-06-08 20:36:46 +03:00
Dmitry Marakasov
482c77e661 Add blank lines between if blocks in miniz_zip.c for readability 2022-06-08 20:32:54 +03:00
Eli Kobrin
a9d7f80cc6 Fix integer overflow in header corruption check. 2022-05-20 16:30:30 +03:00
Dialga
e1e7f70e59
Fix callback typo 2022-05-17 01:37:04 +12:00
Martin Raiber
18bc504331
Merge pull request #224 from Dialga/patch-1
Add switch case for MZ_ZIP_TOTAL_ERRORS
2022-05-08 16:44:03 +02:00
Ozkan Sezer
e285002431 replace use of stdint.h types with mz_ variants 2022-02-09 09:36:50 +03:00
Dialga
5245b1c52f
Add switch case for MZ_ZIP_TOTAL_ERRORS 2022-02-07 11:03:31 +13:00
Martin Raiber
f3d9e2293b
Fix return value 2022-01-22 22:14:31 +01:00
Ozkan Sezer
501a761549 miniz_zip: fix mz_zip_reader_extract_to_heap to read correct sizes
Fixes: https://github.com/richgel999/miniz/issues/218
2022-01-02 20:56:56 +03:00
Martin
13b21dddc7 Remove total files check (its 32-bit uint)
This fixes a compiler warning. The check didn't do
anything since m_total_files is a 32-bit uint and
MZ_UINT32_MAX is actually a valid value.
2021-12-11 12:59:21 +01:00
Martin
a956b4c753 Fix MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 not being set 2021-12-11 12:51:50 +01:00
Martin
72e7267054 Fix unaligned pointer access 2021-11-28 18:37:55 +01:00
Martin
3e5e488ba9 Use level_and_flags after MZ_DEFAULT_COMPRESSION has been handled 2021-11-28 18:08:27 +01:00
Martin
ee4deb08fa Merge remote-tracking branch 'ccawley2011/mingw-watcom'
# Conflicts:
#	examples/example6.c
2021-11-11 21:36:15 +01:00
Ellie
cda0b3e7f0 Fix MinGW cross compilation by removing unneeded capitalization 2021-11-11 13:38:57 +01:00
Zsombor Fazekas
d9c899cea4 Use _wstat64 instead _stat64 on windows 2021-09-16 12:12:07 +02:00
Zsombor Fazekas
70c79cc9d5 Use wfopen on windows 2021-09-16 12:00:44 +02:00
Cameron Cawley
78ae375016 Fix "'&array' may not produce intended result" warnings with OpenWatcom
Co-authored-by: sezero <sezero@users.noreply.github.com>
2021-07-20 18:08:11 +01:00
Cameron Cawley
f542e6df73 Fix "Comparison result always 0" warnings with OpenWatcom 2021-07-20 18:05:16 +01:00
Cameron Cawley
c0aad72d46 Use _ftelli64, _fseeki64 and stat with MinGW32 and OpenWatcom 2021-07-20 18:04:52 +01:00
Martin
75744d32d4 Add flag to set (compressed) size in local file header 2021-02-08 13:49:57 +01:00
Martin Raiber
b43f8a0c22
Merge pull request #147 from andiwand/write-with-dynamic-size
write with dynamic size
2021-02-07 22:03:46 +01:00
Martin Raiber
17d6763721
Merge pull request #154 from wdconinc/patch-1
Fix unused parameter ‘pArray’ in mz_zip_array_range_check
2021-02-07 21:41:07 +01:00
Randy
f52e09a208 mz_zip_validate_file(): fix memory leak on errors
https://oss-fuzz.com/testcase?key=5744008051294208
2020-11-26 02:21:57 +01:00
Wouter Deconinck
fa09b1f3d4
Fix unused parameter ‘pArray’ in mz_zip_array_range_check
When NDEBUG, the assert in mz_zip_array_range_check does nothing and an unused variable warning is generated at 4159f8c8c3/miniz_zip.c (L280)

This commit removes the `|| define (NDEBUG)` so when debugging is turned off, no range check is performed.
2020-04-20 11:19:09 -05:00
Andreas Stefl
1e8c7ce810 write with dynamic size 2020-01-23 17:15:04 +01:00
Syoyo Fujita
a828cc329c ansi mode does not support double-slash comment. Replaced // with /* */ 2019-12-26 14:53:37 +09:00
Your Name
a88d1571c1 Fix missing crc guard
This fixes a warning for an unused variable if `MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS` is on.
2019-12-13 11:22:05 -08:00
Anthony Rabine
5108f95f58 Fix warning (added cast) 2019-10-28 13:50:42 +01:00
Daniel d'Andrada
334e0d64ce Fix LFS check
Code should check for__USE_LARGEFILE64, not _LARGEFILE64_SOURCE

_LARGEFILE64_SOURCE should be used only for setting a preference
when compiling code (either explicitly or by the compiler itself).
Then, according to its value, features.h will take care define things
like __USE_LARGEFILE64 appropriately.

As a side-effect, this patch adds support for clang. When building
with clang one has to explicitly define _LARGEFILE64_SOURCE if he
want to use the *64 api.
2019-10-04 14:11:18 +02:00
tamasmeszaros
d57872c77a Fix for older cmake versions and build of examples. 2019-06-03 10:02:13 +02:00
Martin
a4264837ae Fix type issue 2019-04-11 02:35:18 +02:00
Martin
25de35faec Remove check that path of file added to archive contains ':' or '\' 2019-03-07 14:37:56 +01:00
Martin
4d1d5b6771 Merge branch 'master' of github.com:richgel999/miniz 2019-03-07 14:08:22 +01:00
Martin Raiber
034f0228eb
Merge pull request #122 from FrancescAlted/fix-msvc-warning2
More fixes for warnings MSVC
2019-03-07 14:06:42 +01:00
Martin
6db3c0d290 Don't warn if _LARGEFILE64_SOURCE is not defined 2019-03-07 14:04:15 +01:00
Francesc Alted
96f0da1db9 Yet another fix 2019-03-06 14:34:39 +01:00
Francesc Alted
93c6567773 More fixes for MSVC 2019-03-06 14:07:45 +01:00
Francesc Alted
2b45f89867 Fix a MSVC 2013 warning 2019-03-06 09:51:03 +01:00
paul
45a080c050 Fix large file support under Windows
Under Windows _stat maps to _stat64i32 which only supports max int32_t file sizes.
Change to _stat64 which uses 64bit file sizes and file modification times.
2019-01-23 12:36:25 +10:00
Zach DeVito
a3ca94f833 guard memcpy when n == 0 because buffer may be NULL 2018-11-29 16:56:13 -08:00
Martin
9ce0d0ddff Fix out of bounds read while reading Zip64 extended information 2018-11-11 19:11:47 +01:00