mtools: Corrupted FAT entries when mcopy copies a directory

Chris Lamb lamby at debian.org
Wed Jul 25 13:44:40 BST 2018


tags 837044 + pending patch
tags 900409 + pending patch
tags 900410 + pending patch
thanks

Hi,

After a few pings I've uploaded mtools 4.0.18-2.1 to DELAYED/10:
  
  mtools (4.0.18-2.1) unstable; urgency=medium
  
    * Non-maintainer upload.
    * Prevent an issue where mtools creates corrupted FAT entries for
      directories when copied to a filesystem. This issue was reported upstream
      at <https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html>
      and as the underlying issue is based on uninitialised memory also affects
      the reproducibility of the output of mtools which s required for
      reproducible Debian Installer images. (Closes: #837044, #900409)
    * Use the SOURCE_DATE_EPOCH environment variable if set instead of the
      current time of day as the default timestamp (such as when adding files to
      an existing file) to make its output reproducible. (Closes: #900410)
    * Use "Priority: extra" over "Priority: optional" for Debian Policy  2.0.5.

The full debdiff is attached.


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
diffstat for mtools-4.0.18 mtools-4.0.18

 changelog                                                                 |   16 +++
 control                                                                   |    2 
 patches/02-837044-initialize-direntry.patch                               |   18 +++
 patches/03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch |   47 ++++++++++
 patches/series                                                            |    2 
 5 files changed, 84 insertions(+), 1 deletion(-)

diff -Nru mtools-4.0.18/debian/changelog mtools-4.0.18/debian/changelog
--- mtools-4.0.18/debian/changelog	2014-09-19 09:11:58.000000000 +0800
+++ mtools-4.0.18/debian/changelog	2018-07-25 20:23:59.000000000 +0800
@@ -1,3 +1,19 @@
+mtools (4.0.18-2.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Prevent an issue where mtools creates corrupted FAT entries for
+    directories when copied to a filesystem. This issue was reported upstream
+    at <https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html>
+    and as the underlying issue is based on uninitialised memory also affects
+    the reproducibility of the output of mtools which s required for
+    reproducible Debian Installer images. (Closes: #837044, #900409)
+  * Use the SOURCE_DATE_EPOCH environment variable if set instead of the
+    current time of day as the default timestamp (such as when adding files to
+    an existing file) to make its output reproducible. (Closes: #900410)
+  * Use "Priority: extra" over "Priority: optional" for Debian Policy �� 2.0.5.
+
+ -- Chris Lamb <lamby at debian.org>  Wed, 25 Jul 2018 20:23:59 +0800
+
 mtools (4.0.18-2) unstable; urgency=medium
 
   * Don't have autotools-dev listed twice in Build-depends.
diff -Nru mtools-4.0.18/debian/control mtools-4.0.18/debian/control
--- mtools-4.0.18/debian/control	2014-09-19 09:03:47.000000000 +0800
+++ mtools-4.0.18/debian/control	2018-07-25 20:23:59.000000000 +0800
@@ -1,6 +1,6 @@
 Source: mtools
 Section: otherosfs
-Priority: optional
+Priority: extra
 Maintainer: Anibal Monsalve Salazar <anibal at debian.org>
 Build-Depends: dpkg-dev (>= 1.16.1~), debhelper (>= 9), autotools-dev, libxfont-dev, libxt-dev, texinfo
 Standards-Version: 3.9.6
diff -Nru mtools-4.0.18/debian/patches/02-837044-initialize-direntry.patch mtools-4.0.18/debian/patches/02-837044-initialize-direntry.patch
--- mtools-4.0.18/debian/patches/02-837044-initialize-direntry.patch	1970-01-01 08:00:00.000000000 +0800
+++ mtools-4.0.18/debian/patches/02-837044-initialize-direntry.patch	2018-07-25 20:23:59.000000000 +0800
@@ -0,0 +1,18 @@
+Author: Ronny Nilsson <rln-mtools at arbetsmyra.dyndns.org>
+Description: initialize direntry with memset to correct invalid bitfields
+ mcopy will create directory entries with invalid bitfields because of
+ uninitialized memory.  Initialize this structure with memset() to avoid
+ corrupt filesystems.
+Bug-Ubuntu: https://bugs.launchpad.net/bug/1619718
+Origin: https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html
+
+--- mtools-4.0.18.orig/direntry.c
++++ mtools-4.0.18/direntry.c
+@@ -24,6 +24,7 @@
+ 
+ void initializeDirentry(direntry_t *entry, Stream_t *Dir)
+ {
++	memset(entry, 0, sizeof(direntry_t));
+ 	entry->entry = -1;
+ /*	entry->parent = getDirentry(Dir);*/
+ 	entry->Dir = Dir;
diff -Nru mtools-4.0.18/debian/patches/03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch mtools-4.0.18/debian/patches/03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch
--- mtools-4.0.18/debian/patches/03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch	1970-01-01 08:00:00.000000000 +0800
+++ mtools-4.0.18/debian/patches/03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch	2018-07-25 20:23:59.000000000 +0800
@@ -0,0 +1,47 @@
+--- mtools-4.0.18.orig/misc.c
++++ mtools-4.0.18/misc.c
+@@ -109,7 +109,8 @@ FILE *open_mcwd(const char *mode)
+ 		 * Ignore the info, if the file is more than 6 hours old
+ 		 */
+ 		getTimeNow(&now);
+-		if (now - sbuf.st_mtime > 6 * 60 * 60) {
++		if (now - sbuf.st_mtime > 6 * 60 * 60
++		    && getenv("SOURCE_DATE_EPOCH") == NULL) {
+ 			fprintf(stderr,
+ 				"Warning: \"%s\" is out of date, removing it\n",
+ 				file);
+@@ -159,11 +160,33 @@ void print_sector(const char *message, u
+ 
+ time_t getTimeNow(time_t *now)
+ {
++	char *endptr;
++	char *source_date_epoch;
++	unsigned long long epoch;
+ 	static int haveTime = 0;
+ 	static time_t sharedNow;
+ 
+ 	if(!haveTime) {
+-		time(&sharedNow);
++		source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++		if (source_date_epoch) {
++			epoch = strtoull(source_date_epoch, &endptr, 10);
++
++			if (endptr == source_date_epoch)
++				fprintf(stderr, "SOURCE_DATE_EPOCH invalid\n");
++			else if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
++					|| (errno != 0 && epoch == 0))
++				fprintf(stderr, "SOURCE_DATE_EPOCH: strtoull: %s: %llu\n",
++				strerror(errno), epoch);
++			else if (*endptr != '\0')
++				fprintf(stderr, "SOURCE_DATE_EPOCH has trailing garbage\n");
++			else if (epoch > ULONG_MAX)
++				fprintf(stderr, "SOURCE_DATE_EPOCH must be <= %lu but saw: %llu\n", ULONG_MAX, epoch);
++			else {
++				sharedNow = epoch;
++			}
++		} else {
++			time(&sharedNow);
++		}
+ 		haveTime = 1;
+ 	}
+ 	if(now)
diff -Nru mtools-4.0.18/debian/patches/series mtools-4.0.18/debian/patches/series
--- mtools-4.0.18/debian/patches/series	2013-05-25 12:29:27.000000000 +0800
+++ mtools-4.0.18/debian/patches/series	2018-07-25 20:23:59.000000000 +0800
@@ -1 +1,3 @@
 01-607426-support-zip-files-in-uz.patch
+02-837044-initialize-direntry.patch
+03-837044-corrupted-fat-entries-when-mcopy-copies-directory.patch


More information about the Reproducible-builds mailing list