wgtpkg-zip: fix bug when file's size is zero
[src/app-framework-main.git] / src / wgtpkg-zip.c
index 916d0cd..f7813c4 100644 (file)
@@ -150,20 +150,10 @@ int zread(const char *zipfile, unsigned long long maxsize)
                        ERROR("empty entry found in %s", zipfile);
                        goto error;
                }
-               if (zstat.size == 0) {
-                       /* directory name */
-                       if (zstat.name[len - 1] != '/') {
-                               ERROR("bad directory name %s in %s", zstat.name, zipfile);
-                               goto error;
-                       }
+               if (zstat.name[len - 1] == '/')
                        /* record */
                        fdesc = file_add_directory(zstat.name);
-               } else {
-                       /* directory name */
-                       if (zstat.name[len - 1] == '/') {
-                               ERROR("bad file name %s in %s", zstat.name, zipfile);
-                               goto error;
-                       }
+               else {
                        /* get the size */
                        esize += zstat.size;
                        /* record */
@@ -187,7 +177,9 @@ int zread(const char *zipfile, unsigned long long maxsize)
                assert(fdesc != NULL);
                err = zip_stat_index(zip, fdesc->zindex, ZIP_FL_ENC_GUESS, &zstat);
                assert(zstat.name[0] != '/');
-               if (zstat.size == 0) {
+               len = strlen(zstat.name);
+               assert(len > 0);
+               if (zstat.name[len - 1] == '/') {
                        /* directory name */
                        err = create_directory((char*)zstat.name, MODE_OF_DIRECTORY_CREATION);
                        if (err && errno != EEXIST)