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 2a9e809adc289e91a9ffa6573b0548648dfd2676
Author: jingfei <[email protected]>
AuthorDate: Mon Sep 14 23:42:53 2026 +0800

    fs/zipfs: fix ARCHIVE_EOF NULL deref in zipfs_new
    
    archive_read_next_header2() returns ARCHIVE_EOF (positive) at end of
    archive, clearing the entry so archive_entry_pathname() returns NULL.
    The loop only broke on ret < 0, so on EOF it passed NULL into strcmp()
    and crashed. Break on ARCHIVE_EOF too and guard the NULL name before
    strcmp().
    
    Signed-off-by: jingfei <[email protected]>
    Signed-off-by: tengshuangshuang <[email protected]>
---
 fs/zipfs/zip_vfs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/zipfs/zip_vfs.c b/fs/zipfs/zip_vfs.c
index 5c03fd197d0..96c1ff002cb 100644
--- a/fs/zipfs/zip_vfs.c
+++ b/fs/zipfs/zip_vfs.c
@@ -440,14 +440,20 @@ int zipfs_new(FAR const char *abspath, FAR const char 
*relpath,
 
   while (true)
     {
+      FAR const char *name;
+
       ret = archive_read_next_header2(newp->a, newp->entry);
       ret = zipfs_convert_result(ret);
-      if (ret < 0)
+
+      /* Stop at end of archive (entry cleared, name NULL) or on error */
+
+      if (ret == ARCHIVE_EOF || ret < 0)
         {
           break;
         }
 
-      if (strcmp(archive_entry_pathname(newp->entry), relpath) == 0)
+      name = archive_entry_pathname(newp->entry);
+      if (name != NULL && strcmp(name, relpath) == 0)
         {
           *priv = newp;
           return OK;

Reply via email to