Hi,

harmless bug found during reproducible build tests of new busybox-1.36.1-1 packages for Cygwin distro.

Workaround: 'export TZ=UTC' during build.

--
Regards,
Christian

From 93b59db816482f84223feade753b7186fb9540aa Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Fri, 15 Sep 2023 17:16:07 +0200
Subject: [PATCH] build system: don't use local timezone if SOURCE_DATE_EPOCH
 is specified

The ctime() call after gmtime() may overwrite the static 'struct tm' buffer.

Signed-off-by: Christian Franke <christian.fra...@t-online.de>
---
 scripts/kconfig/confdata.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 249a3195e..7ce5b8088 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -382,13 +382,10 @@ int conf_write(const char *name)
        sym_calc_value(sym);
 
        source_date_epoch = getenv("SOURCE_DATE_EPOCH");
-       if (source_date_epoch && *source_date_epoch) {
+       if (source_date_epoch && *source_date_epoch)
                now = strtoull(source_date_epoch, NULL, 10);
-               build_time = gmtime(&now);
-       } else {
+       else
                time(&now);
-               build_time = localtime(&now);
-       }
 
        env = getenv("KCONFIG_NOTIMESTAMP");
        if (env && *env)
@@ -402,6 +399,13 @@ int conf_write(const char *name)
                     sym_get_string_value(sym),
                     use_timestamp ? "# " : "",
                     use_timestamp ? ctime(&now) : "");
+
+       /* do this after ctime() because it may overwrite the static 'struct 
tm' buf */
+       if (source_date_epoch && *source_date_epoch)
+               build_time = gmtime(&now);
+       else
+               build_time = localtime(&now);
+
        if (out_h) {
                char buf[sizeof("#define AUTOCONF_TIMESTAMP "
                                "\"YYYY-MM-DD HH:MM:SS some_timezone\"\n")];
-- 
2.39.0

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to