mirror of
https://github.com/eledio-devices/thirdparty-miniz.git
synced 2025-11-01 00:38:28 +01:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df65d5a1de | ||
|
|
46cdde2ac5 | ||
|
|
3616bf804b | ||
|
|
76237898c0 | ||
|
|
3af5c82fd3 | ||
|
|
55f4dfe1d2 | ||
|
|
b344eaf775 | ||
|
|
36b6c99f62 | ||
|
|
04f2169b8a | ||
|
|
14a5a1397b | ||
|
|
fef12d34f1 | ||
|
|
b01930542e | ||
|
|
9c88e826a2 | ||
|
|
22e4ef1b1d | ||
|
|
7a7d0b423b | ||
|
|
c17cc20c80 | ||
|
|
0f6b199e5b | ||
|
|
0b7d3070b9 | ||
|
|
aadc405b1c | ||
|
|
02c51d3662 | ||
|
|
9393a95f26 | ||
|
|
82e5b184e4 |
@@ -1,7 +1,12 @@
|
||||
PROJECT(miniz)
|
||||
PROJECT(miniz C)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_CONFIGURATION_TYPES Release Debug)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "")
|
||||
# CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
|
||||
# differentiation between debug and release builds.
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
||||
"Choose the type of build, options are: None (CMAKE_CXX_FLAGS or \
|
||||
CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
|
||||
@@ -38,3 +43,10 @@ endif()
|
||||
|
||||
# add_executable(miniz_tester ${MINIZ_TESTER_SRC_LIST})
|
||||
# target_link_libraries(miniz_tester miniz)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
)
|
||||
file(GLOB INSTALL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||
install(FILES ${INSTALL_HEADERS} DESTINATION include/${PROJECT_NAME})
|
||||
30
ChangeLog.md
30
ChangeLog.md
@@ -1,5 +1,35 @@
|
||||
## Changelog
|
||||
|
||||
### 2.0.8
|
||||
|
||||
- Remove unimplemented functions (mz_zip_locate_file and mz_zip_locate_file_v2)
|
||||
- Add license, changelog, readme and example files to release zip
|
||||
- Fix heap overflow to user buffer in tinfl_status tinfl_decompress
|
||||
- Fix corrupt archive if uncompressed file smaller than 4 byte and file is added by mz_zip_writer_add_mem*
|
||||
|
||||
### 2.0.7
|
||||
|
||||
- Removed need in C++ compiler in cmake build
|
||||
- Fixed loads of uninitilized value errors found with Valgrind by memsetting m_dict to 0 in tdefl_init.
|
||||
- Fix resource leak in mz_zip_reader_init_file_v2
|
||||
- Fix assert with mz_zip_writer_add_mem* w/MZ_DEFAULT_COMPRESSION
|
||||
- cmake build: install library and headers
|
||||
- Remove _LARGEFILE64_SOURCE requirement from apple defines for large files
|
||||
|
||||
### 2.0.6
|
||||
|
||||
- Improve MZ_ZIP_FLAG_WRITE_ZIP64 documentation
|
||||
- Remove check for cur_archive_file_ofs > UINT_MAX, because cur_archive_file_ofs is not used after this point
|
||||
- Add cmake debug configuration
|
||||
- Fix PNG height when creating png files
|
||||
- Add "iterative" file extraction method based on mz_zip_reader_extract_to_callback.
|
||||
- Option to use memcpy for unaligned data access
|
||||
- Define processor/arch macros as zero if not set to one
|
||||
|
||||
### 2.0.4/2.0.5
|
||||
|
||||
- Fix compilation with the various omission compile definitions
|
||||
|
||||
### 2.0.3
|
||||
|
||||
- Fix GCC/clang compile warnings
|
||||
|
||||
@@ -41,9 +41,27 @@ done
|
||||
rm test.out
|
||||
rm main.c
|
||||
|
||||
cp ChangeLog.md amalgamation/
|
||||
cp LICENSE amalgamation/
|
||||
cp readme.md amalgamation/
|
||||
mkdir -p amalgamation/examples
|
||||
cp examples/* amalgamation/examples/
|
||||
|
||||
cd amalgamation
|
||||
! test -e miniz.zip || rm miniz.zip
|
||||
echo -e "miniz.c\nminiz.h" | zip -@ miniz
|
||||
cat << EOF | zip -@ miniz
|
||||
miniz.c
|
||||
miniz.h
|
||||
ChangeLog.md
|
||||
LICENSE
|
||||
readme.md
|
||||
examples/example1.c
|
||||
examples/example2.c
|
||||
examples/example3.c
|
||||
examples/example4.c
|
||||
examples/example5.c
|
||||
examples/example6.c
|
||||
EOF
|
||||
cd ..
|
||||
|
||||
echo "Amalgamation created."
|
||||
|
||||
8
miniz.h
8
miniz.h
@@ -1,4 +1,4 @@
|
||||
/* miniz.c 2.0.6 beta - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
/* miniz.c 2.0.8 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
See "unlicense" statement at the end of this file.
|
||||
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
|
||||
Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
|
||||
@@ -234,11 +234,11 @@ enum
|
||||
MZ_DEFAULT_COMPRESSION = -1
|
||||
};
|
||||
|
||||
#define MZ_VERSION "10.0.1"
|
||||
#define MZ_VERNUM 0xA010
|
||||
#define MZ_VERSION "10.0.3"
|
||||
#define MZ_VERNUM 0xA030
|
||||
#define MZ_VER_MAJOR 10
|
||||
#define MZ_VER_MINOR 0
|
||||
#define MZ_VER_REVISION 1
|
||||
#define MZ_VER_REVISION 3
|
||||
#define MZ_VER_SUBREVISION 0
|
||||
|
||||
#ifndef MINIZ_NO_ZLIB_APIS
|
||||
|
||||
@@ -1334,6 +1334,8 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun
|
||||
d->m_pSrc = NULL;
|
||||
d->m_src_buf_left = 0;
|
||||
d->m_out_buf_ofs = 0;
|
||||
if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG))
|
||||
MZ_CLEAR_OBJ(d->m_dict);
|
||||
memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
|
||||
memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
|
||||
return TDEFL_STATUS_OKAY;
|
||||
|
||||
@@ -540,18 +540,19 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
||||
}
|
||||
}
|
||||
#endif
|
||||
do
|
||||
while(counter>2)
|
||||
{
|
||||
pOut_buf_cur[0] = pSrc[0];
|
||||
pOut_buf_cur[1] = pSrc[1];
|
||||
pOut_buf_cur[2] = pSrc[2];
|
||||
pOut_buf_cur += 3;
|
||||
pSrc += 3;
|
||||
} while ((int)(counter -= 3) > 2);
|
||||
if ((int)counter > 0)
|
||||
counter -= 3;
|
||||
}
|
||||
if (counter > 0)
|
||||
{
|
||||
pOut_buf_cur[0] = pSrc[0];
|
||||
if ((int)counter > 1)
|
||||
if (counter > 1)
|
||||
pOut_buf_cur[1] = pSrc[1];
|
||||
pOut_buf_cur += counter;
|
||||
}
|
||||
|
||||
44
miniz_zip.c
44
miniz_zip.c
@@ -112,7 +112,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
||||
#define MZ_FFLUSH fflush
|
||||
#define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
|
||||
#define MZ_DELETE_FILE remove
|
||||
#elif defined(__APPLE__) && _LARGEFILE64_SOURCE
|
||||
#elif defined(__APPLE__)
|
||||
#ifndef MINIZ_NO_TIME
|
||||
#include <utime.h>
|
||||
#endif
|
||||
@@ -978,7 +978,10 @@ mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename,
|
||||
/* TODO: Better sanity check archive_size and the # of actual remaining bytes */
|
||||
|
||||
if (file_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
|
||||
{
|
||||
MZ_FCLOSE(pFile);
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE);
|
||||
}
|
||||
|
||||
if (!mz_zip_reader_init_internal(pZip, flags))
|
||||
{
|
||||
@@ -3128,14 +3131,15 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
||||
mz_uint16 bit_flags = 0;
|
||||
|
||||
if ((int)level_and_flags < 0)
|
||||
level_and_flags = MZ_DEFAULT_LEVEL;
|
||||
|
||||
if (uncomp_size || (buf_size && !(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
|
||||
bit_flags |= MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
||||
|
||||
if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
|
||||
bit_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
||||
|
||||
if ((int)level_and_flags < 0)
|
||||
level_and_flags = MZ_DEFAULT_LEVEL;
|
||||
level = level_and_flags & 0xF;
|
||||
store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA));
|
||||
|
||||
@@ -3182,6 +3186,17 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
}
|
||||
#endif /* #ifndef MINIZ_NO_TIME */
|
||||
|
||||
if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
||||
{
|
||||
uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size);
|
||||
uncomp_size = buf_size;
|
||||
if (uncomp_size <= 3)
|
||||
{
|
||||
level = 0;
|
||||
store_data_uncompressed = MZ_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
archive_name_size = strlen(pArchive_name);
|
||||
if (archive_name_size > MZ_UINT16_MAX)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
|
||||
@@ -3297,24 +3312,13 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
cur_archive_file_ofs += archive_name_size;
|
||||
}
|
||||
|
||||
if (user_extra_data_len > 0)
|
||||
{
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
||||
if (user_extra_data_len > 0)
|
||||
{
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
||||
|
||||
cur_archive_file_ofs += user_extra_data_len;
|
||||
}
|
||||
|
||||
if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
||||
{
|
||||
uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size);
|
||||
uncomp_size = buf_size;
|
||||
if (uncomp_size <= 3)
|
||||
{
|
||||
level = 0;
|
||||
store_data_uncompressed = MZ_TRUE;
|
||||
}
|
||||
}
|
||||
cur_archive_file_ofs += user_extra_data_len;
|
||||
}
|
||||
|
||||
if (store_data_uncompressed)
|
||||
{
|
||||
|
||||
@@ -237,13 +237,6 @@ MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
|
||||
/* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
|
||||
size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
|
||||
|
||||
/* Attempts to locates a file in the archive's central directory. */
|
||||
/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
|
||||
/* Returns -1 if the file cannot be found. */
|
||||
int mz_zip_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
|
||||
/* Returns MZ_FALSE if the file cannot be found. */
|
||||
mz_bool mz_zip_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex);
|
||||
|
||||
/* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
|
||||
/* Note that the m_last_error functionality is not thread safe. */
|
||||
mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
|
||||
|
||||
Reference in New Issue
Block a user