Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jul 2002 16:16:01 -0700 (PDT)
From:      Martin Müller <martin@bnc.ch>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/40278: mktime returns -1 for certain dates/timezones when it should normalize
Message-ID:  <200207062316.g66NG19j080600@www.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         40278
>Category:       bin
>Synopsis:       mktime returns -1 for certain dates/timezones when it should normalize
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 06 16:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Martin Müller
>Release:        4.6-STABLE
>Organization:
Business Network Communications AG
>Environment:
FreeBSD taos.bnc.ch 4.6-STABLE FreeBSD 4.6-STABLE #0: Sun Jun 16 20:17:27 CEST 2002     root@laguna.bnc.ch:/usr/obj/usr/src/sys/BNC-MP-4.6  i386      
>Description:
When adding one month to Fri Mar  1 02:00:00 2002 and at the same time changing tm_mday to zero (should return last day of March) by calling mktime with a struct tm, the return is -1.

This behaviour seems to occur when using dates that do not really exist because of DST and mktime is not able to recover during normalization.
>How-To-Repeat:
Put your computer in CEST timezone, fill in a struct tm to match
Fri Mar  1 02:00:00 2002, call mktime. Then tm_mon +=1 and tm_mday = 0, call mktime again, this will return -1. If you call mktime two times, changing only one value at a time, the output is correct (because mktime will normalize struct tm correctly).      
>Fix:
Possibly by changing "timesub(&t, ttisp->tt_gmtoff, sp, tmp);"
to "timesub(&t, 0L, sp, tmp);" at ligne 1078 in localtime.c (/usr/src/lib/libc/stdtime/).
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207062316.g66NG19j080600>