libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 24c8d489797499c0331f4d1039e357ece1ae98a7
parent 426a4feb38645fc31e3530a51eef0f683f6e61ad
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun,  5 Aug 2018 22:38:26 +0200

Fix #5405

Diffstat:
MChangeLog | 4++++
Msrc/common/unzip.c | 9++++++---
Msrc/include/extractor.h | 2+-
Msrc/plugins/zip_extractor.c | 22+++++++++++-----------
4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Sun Aug 5 22:37:28 CEST 2018 + Fix missing 0-terminator on corrupted ZIP files + reported by AdLab of Venustech (#5405). -CG + Thu Jul 12 22:26:36 CEST 2018 Fix potential infinite loop in mpeg extractor. Fix build issue with FFmpeg 4.0 (Debian #888373). diff --git a/src/common/unzip.c b/src/common/unzip.c @@ -534,11 +534,11 @@ dos_date_to_tmu_date (uLong ulDosDate, * @param pfile_info file information to initialize * @param pfile_info_internal internal file information to initialize * @param szFileName where to write the name of the current file - * @param fileNameBufferSize number of bytes available in szFileName + * @param fileNameBufferSize number of bytes available in @a szFileName * @param extraField where to write extra data * @param extraFieldBufferSize number of bytes available in extraField * @param szComment where to write the comment on the current file - * @param commentBufferSize number of bytes available in szComment + * @param commentBufferSize number of bytes available in @a szComment * @return #EXTRACTOR_UNZIP_OK if there is no problem. */ static int @@ -664,7 +664,10 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file, uSizeRead = file_info.size_file_comment; } else - uSizeRead = commentBufferSize; + { + *(szComment+commentBufferSize - 1) = '\0'; + uSizeRead = commentBufferSize - 1; + } if (0 != lSeek) { diff --git a/src/include/extractor.h b/src/include/extractor.h @@ -35,7 +35,7 @@ extern "C" { * 0.2.6-1 => 0x00020601 * 4.5.2-0 => 0x04050200 */ -#define EXTRACTOR_VERSION 0x01070000 +#define EXTRACTOR_VERSION 0x01070001 #include <stdio.h> diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c @@ -6,7 +6,7 @@ * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 3, or (at your * option) any later version. - * + * * libextractor is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -16,7 +16,7 @@ * along with libextractor; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - */ + */ /** * @file plugins/zip_extractor.c * @brief plugin to support ZIP files @@ -27,9 +27,9 @@ #include "extractor.h" #include "unzip.h" - + /** - * Main entry method for the 'application/zip' extraction plugin. + * Main entry method for the 'application/zip' extraction plugin. * * @param ec extraction context provided to the plugin */ @@ -57,12 +57,12 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) } if (EXTRACTOR_UNZIP_OK != EXTRACTOR_common_unzip_go_to_first_file (uf)) - { + { /* zip malformed? */ goto CLEANUP; } if (0 != - ec->proc (ec->cls, + ec->proc (ec->cls, "zip", EXTRACTOR_METATYPE_MIMETYPE, EXTRACTOR_METAFORMAT_UTF8, @@ -77,7 +77,7 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) { if ( (0 != strlen (fcomment)) && (0 != - ec->proc (ec->cls, + ec->proc (ec->cls, "zip", EXTRACTOR_METATYPE_COMMENT, EXTRACTOR_METAFORMAT_C_STRING, @@ -99,7 +99,7 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) { if ( (0 != strlen (fname)) && (0 != - ec->proc (ec->cls, + ec->proc (ec->cls, "zip", EXTRACTOR_METATYPE_FILENAME, EXTRACTOR_METAFORMAT_C_STRING, @@ -109,7 +109,7 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) goto CLEANUP; if ( (0 != strlen (fcomment)) && (0 != - ec->proc (ec->cls, + ec->proc (ec->cls, "zip", EXTRACTOR_METATYPE_COMMENT, EXTRACTOR_METAFORMAT_C_STRING, @@ -117,11 +117,11 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec) fcomment, strlen (fcomment) + 1))) goto CLEANUP; - } + } } while (EXTRACTOR_UNZIP_OK == EXTRACTOR_common_unzip_go_to_next_file (uf)); - + CLEANUP: (void) EXTRACTOR_common_unzip_close (uf); }