Package: mtools
Version: 4.0.18-2
Severity: important
Tags: patch
User: [email protected]
Usertags: origin-ubuntu yakkety ubuntu-patch

Hi Anibal,

Current versions of mtools will create corrupted FAT entries for directories
when copied to a filesystem, due to uninitialized memory (resulting from a
change in behavior of gcc which is itself correct).  This issue was first
reported upstream at
https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html in
2014, but upstream seems quite inactive and no action appears to have been
taken.  We ran into this issue in Ubuntu
(https://bugs.launchpad.net/bug/1619718) and have applied the proposed fix
for this dataloss bug.  Please consider applying it in Debian as well.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[email protected]                                     [email protected]
diff -Nru mtools-4.0.18/debian/patches/initialize-direntry.patch mtools-4.0.18/debian/patches/initialize-direntry.patch
--- mtools-4.0.18/debian/patches/initialize-direntry.patch	1969-12-31 16:00:00.000000000 -0800
+++ mtools-4.0.18/debian/patches/initialize-direntry.patch	2016-09-07 23:48:56.000000000 -0700
@@ -0,0 +1,19 @@
+Author: Ronny Nilsson <[email protected]>
+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
+
+diff -rup mtools-4.0.18.orig/direntry.c mtools-4.0.18/direntry.c
+--- mtools-4.0.18.orig/direntry.c	2010-10-11 21:18:53.000000000 +0000
++++ mtools-4.0.18/direntry.c	2014-08-27 16:44:32.984959149 +0000
+@@ -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/series mtools-4.0.18/debian/patches/series
--- mtools-4.0.18/debian/patches/series	2013-05-24 21:29:27.000000000 -0700
+++ mtools-4.0.18/debian/patches/series	2016-09-07 23:30:36.000000000 -0700
@@ -1 +1,2 @@
 01-607426-support-zip-files-in-uz.patch
+initialize-direntry.patch

Reply via email to