From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 8FA94217CB for ; Mon, 25 Mar 2024 21:31:04 +0100 (CET) Received: (qmail 20152 invoked by uid 550); 25 Mar 2024 20:26:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 20110 invoked from network); 25 Mar 2024 20:26:17 -0000 Date: Mon, 25 Mar 2024 16:31:10 -0400 From: Rich Felker To: Alexander Weps Cc: musl@lists.openwall.com Message-ID: <20240325203110.GK4163@brightrain.aerifal.cx> References: <20240325131318.GD4163@brightrain.aerifal.cx> <20240325134252.GE4163@brightrain.aerifal.cx> <20240325180208.GF4163@brightrain.aerifal.cx> <20240325185339.GG4163@brightrain.aerifal.cx> <4-8Ne4x6ZXfJmyaJ2YBFpLfCYySv9--JLQJl9OcSwaKyCashDhJXsqAPuh7G8QYwQpn2JnjUJxfZX8t9Fo101Mg_6rwb_MpmbRhFRUpYoz8=@pm.me> <20240325193813.GH4163@brightrain.aerifal.cx> <20240325202329.GJ4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="krsqJi1PDCheOQxO" Content-Disposition: inline In-Reply-To: <20240325202329.GJ4163@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Broken mktime calculations when crossing DST boundary --krsqJi1PDCheOQxO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 25, 2024 at 04:23:29PM -0400, Rich Felker wrote: > > Also, can you share the whole code, you did some changes and I don't > > reproduce the result. Which sample it is based on? > > https://www.openwall.com/lists/musl/2024/03/25/11 > > The only change I made was tm_isdst=1 (you already had tm_mday=31 > there). I'll attach the file anyway though. Forgot to attach. Here it is. --krsqJi1PDCheOQxO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test10.c" #include #include #include void test10() { time_t t = 0; struct tm tm = {0}; char buf[64]; tm.tm_year = 2011 - 1900; tm.tm_mon = 12 - 1; tm.tm_mday = 31; // <-- here is the change tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = 1; strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("before: %s %ld\n", buf, t); t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after1: %s %ld\n", buf, t); tm.tm_mday -= 1; t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after2: %s %ld\n", buf, t); tm.tm_mday += 1; t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after3: %s %ld\n", buf, t); } int main(int argc, char *argv[]) { test10(); return 0; } --krsqJi1PDCheOQxO--