History log of /openbsd-current/lib/libc/time/localtime.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.66 04-Apr-2024 millert

tzset_basic: only call issetugid(2) if TZ has changed
If we are just going to return without parsing TZ, there is no need
to call issetugid(2) first. We only need to call issetugid(2) the
first time TZ is checked or when the value of TZ has changed.
Previously, we called issetugid(2) for every call to the functions
described by localtime(3). OK deraadt@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.65 03-Oct-2022 millert

Allow TZ to contain absolutes paths starting with /usr/share/zoneinfo/
Other absolutes paths are still rejected.


Revision tags: OPENBSD_7_2_BASE
# 1.64 23-Sep-2022 millert

POSIX timzone specs may contain '.' so only reject names containing '../'.
Noted by pjanzen@ with input from deraadt@.


# 1.63 21-Sep-2022 millert

tzset: ignore TZ if it contains an absolute path or issetugid().
Reading time zone files from user-controlled paths can result in
pledge(2) or unveil(2) violations. We also ignore files that contain
a '.' character to avoid paths containing ".." or hidden files.
Work with and OK deraadt@


# 1.62 25-Aug-2022 millert

No need to include float.h anymore.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.65 03-Oct-2022 millert

Allow TZ to contain absolutes paths starting with /usr/share/zoneinfo/
Other absolutes paths are still rejected.


Revision tags: OPENBSD_7_2_BASE
# 1.64 23-Sep-2022 millert

POSIX timzone specs may contain '.' so only reject names containing '../'.
Noted by pjanzen@ with input from deraadt@.


# 1.63 21-Sep-2022 millert

tzset: ignore TZ if it contains an absolute path or issetugid().
Reading time zone files from user-controlled paths can result in
pledge(2) or unveil(2) violations. We also ignore files that contain
a '.' character to avoid paths containing ".." or hidden files.
Work with and OK deraadt@


# 1.62 25-Aug-2022 millert

No need to include float.h anymore.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.64 23-Sep-2022 millert

POSIX timzone specs may contain '.' so only reject names containing '../'.
Noted by pjanzen@ with input from deraadt@.


# 1.63 21-Sep-2022 millert

tzset: ignore TZ if it contains an absolute path or issetugid().
Reading time zone files from user-controlled paths can result in
pledge(2) or unveil(2) violations. We also ignore files that contain
a '.' character to avoid paths containing ".." or hidden files.
Work with and OK deraadt@


# 1.62 25-Aug-2022 millert

No need to include float.h anymore.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.63 21-Sep-2022 millert

tzset: ignore TZ if it contains an absolute path or issetugid().
Reading time zone files from user-controlled paths can result in
pledge(2) or unveil(2) violations. We also ignore files that contain
a '.' character to avoid paths containing ".." or hidden files.
Work with and OK deraadt@


# 1.62 25-Aug-2022 millert

No need to include float.h anymore.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.62 25-Aug-2022 millert

No need to include float.h anymore.


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.61 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.60 12-May-2019 schwarze

Unifdef TM_GMTOFF TM_ZONE USG_COMPAT ALTZONE to make the code more readable.
No binary change when compiled with -g0.
Note that wcsftime.c did not even compile without TM_ZONE.
OK millert@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.59 19-Sep-2016 millert

gmtime_r() should return NULL on failure, not the struct tm * result
parameter that was passed in. From Carlin Bingham.


Revision tags: OPENBSD_6_0_BASE
# 1.58 14-Mar-2016 mestre

Remove doaccess variable and access(2) call since this interfers with
applications like zdump(8) because pledge(2) doesn't allow access(2) to
/usr/share/zoneinfo.

millert@ better described why this call can go away:

"This looks like an attempt to do access checks based on the real uid instead
of the effective uid. Basically for setuid programs we don't want to allow a
user to set TZ to a path they should not be able to otherwise access.

However, we already have a check for issetugid() above so I think the doaccess
bits can just be removed and we can rely on open()."

After discussion with tb@, deraadt@ and millert@, this was also OK'ed by them


Revision tags: OPENBSD_5_9_BASE
# 1.57 12-Dec-2015 mmcc

Remove calloc cast, give sizeof parens. No functional change.


# 1.56 01-Nov-2015 guenther

delete old lint ARGSUSED comments


# 1.55 24-Oct-2015 guenther

Move #includes from private.h to the .c files that need them, getting rid of
several. Switch from FILENAME_MAX to PATH_MAX (it's for open(), not fopen()).

ok deraadt@ tedu@ krw@


# 1.54 19-Sep-2015 guenther

Don't wrap initialized variables: binutils appears to be mishandling them
on arm and m88k

problems with optind observed by jsg@


# 1.53 12-Sep-2015 guenther

Wrap <time.h> so that internal calls go direct and symbols not in C99 are weak
Add prototypes to localtime.c for offtime(), time2posix(), posix2time() to
reduce noise with -Wmissing-prototypes
Eliminate unnecessary #includes


Revision tags: OPENBSD_5_8_BASE
# 1.52 07-Apr-2015 millert

Remove obsolete timezone() function.
Add timezone and daylight symbols for XSI compatibility.


Revision tags: OPENBSD_5_7_BASE
# 1.51 16-Feb-2015 tedu

sprinkle braces around multi line statements


# 1.50 16-Feb-2015 tedu

pull scopes without conditionals up into enclosing block


# 1.49 16-Feb-2015 tedu

knf indents to give me a fighting chance at differentiating new blocks
from continuation lines, of which there are many


# 1.48 16-Feb-2015 tedu

drop an ansi bomb on the function definitions


# 1.47 10-Feb-2015 tedu

remove CMU gtime


# 1.46 09-Feb-2015 tedu

it is not strictly necessary to cast the "return value" of free() to void.


# 1.45 09-Feb-2015 tedu

- register int idays; /* unsigned would be so 2003 */
+ int idays; /* unsigned would be so 2003 */

register is so 1973


# 1.44 09-Feb-2015 tedu

always define ALL_STATE (which, contrary to the name is not about all
states, but rather heap allocating the state) and unifdef the rest


# 1.43 09-Feb-2015 tedu

the one true type of time_t is a signed integer


# 1.42 09-Feb-2015 tedu

remove INITIALIZE macro and do it the hard way.


# 1.41 09-Feb-2015 tedu

move include lines around a bit


# 1.40 09-Feb-2015 tedu

replace homegrown is_digit with correct calls to isdigit()


# 1.39 09-Feb-2015 tedu

this removes just a few ifdef checks for things that should always be enabled,
and which we definitely don't want to workaround. no change in the compiled
code (yet).
some of these, like the first chunk are plain silly. the compiler used to
compile asctime has nothing to do with the format strings strftime should
support.
ok deraadt


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.38 17-Apr-2013 tedu

add some prototypes, casts, includes, parenthesis, and whatnot to
silence some warnings.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.37 25-Apr-2011 millert

Update to tzcode2011g from elsie.nci.nih.gov.


Revision tags: OPENBSD_4_9_BASE
# 1.36 30-Nov-2010 tedu

replace a large stack buffer with a malloc call, with help from matthew.
ok deraadt
[passed upstream to the tz list as well]


# 1.35 23-Aug-2010 millert

update to tzcode2010k from elsie.nci.nih.gov; OK miod@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.34 31-Mar-2008 millert

Update to tzcode 2008a from elsie.nci.nih.gov


Revision tags: OPENBSD_4_3_BASE
# 1.33 29-Dec-2007 millert

update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.32 06-Feb-2007 millert

Update to tzcode2007a. This adds support for 64bit time_t in case
we need it in the future. All of our platforms currently have 32bit
time_t types. This also extends the timezone data file format to
support both 32bit and 64bit data. The 64bit data is located after
the 32bit data so binaries linked with the older tzcode simply won't
look at it. A version field in the file header is used to determine
whether the data file is the old or extended format. OK miod@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.31 18-Feb-2006 millert

Update to tzcode2006a; primarily just cast and const fixes.


Revision tags: OPENBSD_3_8_BASE
# 1.30 09-Aug-2005 millert

Re-add the change from tzcode2005c, this time with an added bounds
check from Arthur David Olson that fixes a possible infinite loop.


# 1.29 09-Aug-2005 millert

Back out a change from tzcode2005c that can cause an infinite loop in mktime().


# 1.28 09-Aug-2005 millert

Do not ignore return value of localsub() in localtime_r()


# 1.27 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.26 05-Jul-2005 millert

Update to tzcode2005j.


Revision tags: OPENBSD_3_7_BASE
# 1.25 18-Oct-2004 millert

Update to tzcode2004e from elsie.nci.nih.gov


Revision tags: OPENBSD_3_6_BASE
# 1.24 28-Jun-2004 millert

merge in tzcode2004a


Revision tags: OPENBSD_3_5_BASE
# 1.23 06-Oct-2003 millert

Update to tzcode2003c from elsie.nci.nih.gov
Fixes a pasto and implements better int oflow checking (doesn't rely on
unspecified behavior).


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE
# 1.22 13-Mar-2003 deraadt

a few more strlcy; ok from beck & ho


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.21 04-Apr-2002 millert

Minor updates from tzcode2002c


Revision tags: OPENBSD_3_0_BASE
# 1.20 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.19 16-Apr-2000 d

sync with ftp://elsie.nci.nih.gov/pub/tzcode2000c.tar.gz, millert@ ok


# 1.18 06-Jan-2000 d

_THREAD_PRIVATE_* macros changed


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.17 09-Mar-1999 pjanzen

Back out rev 1.7. PCTS 151-2 still passes, and mktime() now correctly returns
-1 for calendar times that cannot be represented.


# 1.16 02-Feb-1999 d

typo


# 1.15 01-Feb-1999 d

sync with tzcode1999a


# 1.14 20-Nov-1998 d

Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO


Revision tags: OPENBSD_2_4_BASE
# 1.13 11-Jul-1998 deraadt

be... slightly more permissive.. but i think this is right, i looked at it for 5 minutes


# 1.12 11-Jul-1998 deraadt

do not let :relative paths through (how did i miss this before)


Revision tags: OPENBSD_2_3_BASE
# 1.11 18-Jan-1998 millert

tzcode1998b from ftp://elsie.nci.nih.gov/pub


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.10 02-Apr-1997 deraadt

correctly code the classes of permitted TZ specifications for the
issetugid() case. thanks bitblt and tholo


# 1.9 21-Jan-1997 millert

Remove unnecesary local changes. The strncpy()'s are safe because
the string is static and so the last element is always init'd to
zero.


# 1.8 14-Jan-1997 millert

Update to tzcode1996o + our fixes. Fixes problem pointed out
by cross@va.pubnix.com.


# 1.7 30-Oct-1996 tholo

iUpdate to pass FIPS 151-2 tests


Revision tags: OPENBSD_2_0_BASE
# 1.6 05-Sep-1996 deraadt

1 char oflow


# 1.5 25-Aug-1996 deraadt

use issetugid()


# 1.4 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.3 29-Jan-1996 deraadt

new common tz code


# 1.2 11-Jan-1996 deraadt

from netbsd; sync with tzcode96a


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision