info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Info-mtools] [PATCH] Ensure that directory entries use gmtime(3) over l


From: Chris Lamb
Subject: [Info-mtools] [PATCH] Ensure that directory entries use gmtime(3) over localtime(3).
Date: Tue, 02 May 2023 10:36:58 -0700
User-agent: Cyrus-JMAP/3.9.0-alpha0-386-g2404815117-fm-20230425.001-g24048151

[I've included Alper Nebi Yasak's original bug report below this patch.]

§

From: Chris Lamb <lamby@debian.org>
Date: Tue, 2 May 2023 09:49:10 -0700
Subject: [PATCH] Ensure that directory entries use gmtime(3) over
 localtime(3).

This was originally reported by Alper Nebi Yasak <alpernebiyasak@gmail.com>
in Debian bug #1035375 <https://bugs.debian.org/1035375>.

I can confirm that Alper's minimal testcase fails without this change (and
passes with it).


Signed-off-by: Chris Lamb <lamby@debian.org>
---
 directory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/directory.c b/directory.c
index 7625699..4a49411 100644
--- a/directory.c
+++ b/directory.c
@@ -104,7 +104,7 @@ struct directory *mk_entry(const dos_name_t *dn, unsigned 
char attr,
        uint8_t hour, min_hi, min_low, sec;
        uint8_t year, month_hi, month_low, day;
 
-       now = localtime(&date2);
+       now = gmtime(&date2);
        dosnameToDirentry(dn, ndir);
        ndir->attr = attr;
        ndir->ctime_ms = 0;
-- 
2.40.1


§


----- Original message -----
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Bug#1035375: mtools: interprets SOURCE_DATE_EPOCH in system timezone 
instead of UTC
Date: Tuesday, 2 May 2023 4:00 AM

Package: mtools
Version: 4.0.33-1+really4.0.32-1
Severity: wishlist
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps toolchain
X-Debbugs-Cc: reproducible-bugs@lists.alioth.debian.org


Hi,

I came across timestamp differences in FAT filesystem images while
trying to build debian-installer with debrepro (among many other
things), and tracked it down to mmd/mcopy calls. Here's a short reproducer:

  export SOURCE_DATE_EPOCH="$(date "+%s")"

  imgprep() {
    [ -f "$1" ] && rm "$1"
    mkfs.msdos --invariant -v -i deb00001 -C "$1" 512
    mmd -i "$1" ::foo
    mcopy -i "$1" "$2" ::bar
  }

  dd if=/dev/random of=rand.img bs=512 count=200

  TZ=UTC   imgprep first.img rand.img
  TZ=UTC-3 imgprep second.img rand.img

  diffoscope first.img second.img

which shows an exact 3-hour difference in timestamps for me. AFAICT,
SOURCE_DATE_EPOCH is meant to be in UTC, so embedded timestamps and the
two files should be the same regardless of TZ or system timezone.

Attachment: 0001-Ensure-that-directory-entries-use-gmtime-3-over-loca.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]