From 2ecf2ce63a51d4b35df37dbfb8aeace1a8aa04bc Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Mon, 29 Oct 2018 16:31:46 -0400 Subject: [PATCH] initializeDirentry: Zero-out entry direntry_t before using it Whilst working on the Reproducible Builds effort [0] we noticed that mtools does not operate on images in a reproducibile manner and can even create corrupted FAT entries for directories when when mcopy copies a directory. This is due to writing unintialised memory and is fixed by a memset(3). The issue and patch were independently in both Debian bug #837044 [1] and then a few years later in #900409 [2] when attempting to create reproducible Debian Installer images. It was forwarded upstream at [3] but was seemingly not applied (the fix is not present in recent 4.0.19 tarball). [0] https://reproducible-builds.org/ [1] https://bugs.debian.org/837044 [2] https://bugs.debian.org/900409 [3] https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html --- direntry.c | 1 + 1 file changed, 1 insertion(+) diff --git a/direntry.c b/direntry.c index c1d2ddd..284d0ae 100644 --- a/direntry.c +++ b/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; -- 2.19.1