From 7cf2890d871e76c082528565f59e1d0d1055b7f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 23 Feb 2017 10:47:13 +0100 Subject: [PATCH] Fix readdir that doesn't return dt_type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is an incomplete fix. More readdir calls exists that should be treated. Change-Id: Ib80c9f4ac8fe7ce02d22968a9cf37f7841514f57 Signed-off-by: José Bollo --- src/wgtpkg-zip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wgtpkg-zip.c b/src/wgtpkg-zip.c index e450c0f..a182261 100644 --- a/src/wgtpkg-zip.c +++ b/src/wgtpkg-zip.c @@ -243,6 +243,7 @@ static int zwr(struct zws *zws, size_t offset) zip_int64_t z64; struct zip_source *zsrc; FILE *fp; + struct stat st; fd = openat(workdirfd, offset ? zws->name : ".", O_DIRECTORY|O_RDONLY); if (fd < 0) { @@ -275,6 +276,13 @@ static int zwr(struct zws *zws, size_t offset) ERROR("invalid name %s", zws->name); goto error; } + if (ent->d_type == DT_UNKNOWN) { + fstatat(fd, ent->d_name, &st, 0); + if (S_ISREG(st.st_mode)) + ent->d_type = DT_REG; + else if (S_ISDIR(st.st_mode)) + ent->d_type = DT_DIR; + } switch (ent->d_type) { case DT_DIR: z64 = zip_dir_add(zws->zip, zws->name, ZIP_FL_ENC_UTF_8); -- 2.16.6