This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3a59ec10eeb813c881cbbffccb67f541582ef8dc Author: anjiahao <[email protected]> AuthorDate: Tue Dec 17 20:01:07 2024 +0800 zipfs:use unzCloseCurrentFile to check crc when read done zipfs_close() calls unzCloseCurrentFile() before unzClose(). When the file was read completely, minizip checks its CRC in unzCloseCurrentFile(). A CRC error is logged and close() returns -ESTALE for it. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: anjiahao <[email protected]> Signed-off-by: tengshuangshuang <[email protected]> --- fs/zipfs/zip_vfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/zipfs/zip_vfs.c b/fs/zipfs/zip_vfs.c index 85d22dc1057..b6e0201b76e 100644 --- a/fs/zipfs/zip_vfs.c +++ b/fs/zipfs/zip_vfs.c @@ -26,6 +26,7 @@ #include <assert.h> #include <errno.h> +#include <debug.h> #include <fcntl.h> #include <string.h> #include <sys/stat.h> @@ -231,6 +232,7 @@ static int zipfs_convert_result(int ziperr) case UNZ_END_OF_LIST_OF_FILE: return -ENOENT; case UNZ_CRCERROR: + ferr("zipfs file crc error\n"); return -ESTALE; case UNZ_INTERNALERROR: return -EPERM; @@ -301,12 +303,17 @@ static int zipfs_close(FAR struct file *filep) { FAR struct zipfs_file_s *fp = filep->f_priv; int ret; + int ret1; + + /* If read done, will check crc in unzCloseCurrentFile */ + + ret = zipfs_convert_result(unzCloseCurrentFile(fp->uf)); + ret1 = zipfs_convert_result(unzClose(fp->uf)); - ret = zipfs_convert_result(unzClose(fp->uf)); nxmutex_destroy(&fp->lock); fs_heap_free(fp->seekbuf); fs_heap_free(fp); - return ret; + return ret < 0 ? ret : ret1; } static ssize_t zipfs_read(FAR struct file *filep, FAR char *buffer,
