19936161 zip incorrectly treats S_IF* as bitmasks, not values
authorJiri Kukacka <jiri.kukacka@oracle.com>
Wed, 03 Dec 2014 06:13:04 -0800
changeset 3540 4f3892464f83
parent 3538 238a81aec08a
child 3541 37a03b73b5a4
19936161 zip incorrectly treats S_IF* as bitmasks, not values
components/zip/patches/03-s_is-fix.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/zip/patches/03-s_is-fix.patch	Wed Dec 03 06:13:04 2014 -0800
@@ -0,0 +1,76 @@
+# developed in house, fed back, already fixed in development version.
+# reported to http://www.info-zip.org/zip-bug.html
+# patch fixes usage of S_IF* using macros instead of incorrect access as if
+# it was bitmask.
+
+
+--- zip30/unix/unix.c.old       2008-06-18 21:26:18.000000000 -0700
++++ zip30/unix/unix.c   2014-11-19 10:02:32.388243582 -0800
[email protected]@ -140,7 +140,7 @@
+   }
+ 
+   /* Live name--use if file, recurse if directory */
+-#ifdef OS390
++#if defined(S_ISREG) && defined(S_ISLINK)
+   if (S_ISREG(s.st_mode) || S_ISLNK(s.st_mode))
+ #else
+ #  ifdef S_IFLNK
[email protected]@ -154,7 +154,7 @@
+     if ((m = newname(n, 0, caseflag)) != ZE_OK)
+       return m;
+   }
+-#ifdef OS390
++#ifdef S_ISDIR
+   else if (S_ISDIR(s.st_mode))
+ #else
+   else if ((s.st_mode & S_IFDIR) == S_IFDIR)
[email protected]@ -202,7 +202,7 @@
+     }
+     free((zvoid *)p);
+   } /* (s.st_mode & S_IFDIR) */
+-#ifdef OS390
++#ifdef S_ISFIFO
+   else if (S_ISFIFO(s.st_mode))
+ #else
+   else if ((s.st_mode & S_IFIFO) == S_IFIFO)
[email protected]@ -418,12 +418,20 @@
+     *a = ((ulg)legacy_modes << 16) | !(s.st_mode & S_IWRITE);
+     }
+ #endif
++#ifdef S_ISDIR
++    if (S_ISDIR(s.st_mode)) {
++#else
+     if ((s.st_mode & S_IFMT) == S_IFDIR) {
++#endif
+       *a |= MSDOS_DIR_ATTR;
+     }
+   }
+   if (n != NULL)
++#ifdef S_ISDIR
++    *n = S_ISDIR(s.st_mode) ? s.st_size : -1L;
++#else
+     *n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
++#endif
+   if (t != NULL) {
+     t->atime = s.st_atime;
+     t->mtime = s.st_mtime;
+--- zip30/fileio.c.old  2008-05-28 17:13:24.000000000 -0700
++++ zip30/fileio.c      2014-11-19 10:36:59.461855532 -0800
[email protected]@ -1114,6 +1114,9 @@
+ /* Return true if the attributes are those of a symbolic link */
+ {
+ #ifndef QDOS
++#ifdef S_ISLNK
++  return S_ISLNK(a >> 16);
++#else
+ #ifdef S_IFLNK
+ #ifdef __human68k__
+   int *_dos_importlnenv(void);
[email protected]@ -1125,6 +1128,7 @@
+ #else /* !S_IFLNK */
+   return (int)a & 0;    /* avoid warning on unused parameter */
+ #endif /* ?S_IFLNK */
++#endif /* ?S_ISLNK */
+ #else
+   return 0;
+ #endif