CVE-1999-0199 (Other, published 2020-10-06T13:15Z)
Description: value: manual/search.texi in the GNU C Library (aka glibc) before 2.2 lacks a statement about the unspecified tdelete return value upon deletion of a tree's root, which might allow attackers to access a dangling pointer in an application whose developer was unaware of a documentation update from 1999.
Severity: HIGH (CVSS v3 base score: 9.8)
Weakness: CWE-252 \u2014 Unchecked Return Value
The product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions.
Repository: https://github.com/bminor/glibc
Files changed:
ChangeLog
elf/dl-load.c
manual/search.texi
misc/syslog.c
posix/Makefile
posix/regex.c
posix/tst-getlogin.c
sysdeps/unix/getlogin_r.c
sysdeps/unix/sysv/linux/bits/resource.h
timezone/africa
timezone/asia
timezone/australasia
timezone/backward
timezone/checktab.awk
timezone/europe
timezone/iso3166.tab
timezone/northamerica
timezone/southamerica
timezone/zone.tab
Commit message: Update.

1999-11-09  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-load.c (_dl_dst_count): Allow $ORIGIN to point to
	directory with the reference since this is as secure as using the
	object with the dependency.
	(_dl_dst_substitute): Likewise.

	* elf/dl-load.c (_dl_dst_count): Change strings in first two
	strncmp calls to allow reuse.
	(_dl_dst_substitute): Likewise.

1999-11-01  Arnold D. Robbins  <arnold@skeeve.com>

	* posix/regex.c (init_syntax_once): move below definition of
	ISALNUM etc., then use ISALNUM to init the table, so that
	the word ops will work if i18n'ed.
	(SYNTAX): And subscript with 0xFF for 8bit character sets.

1999-11-09  Andreas Jaeger  <aj@suse.de>

	* sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin
	implementation for ttyname_r call; fix inverted condition; return
	ut_user.  Closes PR libc/1438.

1999-11-09  Ulrich Drepper  <drepper@cygnus.com>

	* timezone/checktab.awk: Update from tzcode1999h.
	* timezone/africa: Update from tzdata1999i.
	* timezone/asia: Likewise.
	* timezone/australasia: Likewise.
	* timezone/backward: Likewise.
	* timezone/europe: Likewise.
	* timezone/northamerica: Likewise.
	* timezone/southamerica: Likewise.
	* timezone/iso3166.tab: Likewise.
	* timezone/zone.tab: Likewise.

	* sysdeps/unix/sysv/linux/bits/resource.h: Define values also as
	macros.  Patch by brg@csua.berkeley.edu [PR libc/1439].

1999-11-09  Andreas Jaeger  <aj@suse.de>

	* posix/Makefile (tests): Added tst-getlogin.

	* posix/tst-getlogin.c: New file, contains simple tests for
	getlogin and getlogin_r.

1999-11-09  Andreas Schwab  <schwab@suse.de>

	* misc/syslog.c: For LOG_PERROR only append a newline if
	necessary.


Vulnerable code:
      /* $ORIGIN is not expanded for SUID/GUID programs.  */
      if ((((!__libc_enable_secure
	     && strncmp (&name[1], "ORIGIN", 6) == 0 && (len = 7) != 0)
	    || (strncmp (&name[1], "PLATFORM", 8) == 0 && (len = 9) != 0))
	      && ((!__libc_enable_secure
		   && strncmp (&name[2], "ORIGIN}", 7) == 0 && (len = 9) != 0)
	  if ((((strncmp (&name[1], "ORIGIN", 6) == 0 && (len = 7) != 0)
		|| (strncmp (&name[1], "PLATFORM", 8) == 0 && (len = 9) != 0))
		      ? (__libc_enable_secure ? NULL : l->l_origin)
  /* Determine the nubmer of DST elements.  */
and the data if this tree node is returned by the function.  If there is
no matching entry in the tree nothing can be deleted and the function
returns @code{NULL}.
		++v;
		v->iov_base = (char *) "\n";
		v->iov_len = 1;
		(void)__writev(STDERR_FILENO, iov, 2);
		   tst-preadwrite test-vfork regexbug1
/* How many characters in the character set.  */
# define CHAR_SET_SIZE 256

# ifdef SYNTAX_TABLE

extern char *re_syntax_table;

# else /* not SYNTAX_TABLE */

static char re_syntax_table[CHAR_SET_SIZE];

static void
init_syntax_once ()
{
   register int c;
   static int done;

   if (done)
     return;

   bzero (re_syntax_table, sizeof re_syntax_table);

   for (c = 'a'; c <= 'z'; c++)
     re_syntax_table[c] = Sword;

   for (c = 'A'; c <= 'Z'; c++)
     re_syntax_table[c] = Sword;

   for (c = '0'; c <= '9'; c++)
     re_syntax_table[c] = Sword;

   re_syntax_table['_'] = Sword;

   done = 1;
}

# endif /* not SYNTAX_TABLE */

# define SYNTAX(c) re_syntax_table[c]

  {
    int d = __open ("/dev/tty", 0);
    if (d < 0)
      return errno;
    result = __ttyname_r (d, real_tty_path, sizeof (tty_pathname));
    (void) __close (d);

    if (result != 0)
      {
	__set_errno (result);
	return result;
      }
  }
      size_t needed = strlen (ut->ut_line) + 1;
      if (needed < name_len)
	  memcpy (name, ut->ut_line, needed);
# @(#)africa	7.31
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
#
# From Shanks, as corrected by Whitman:
Rule	Libya	1990	only	-	May	 4	0:00	1:00	S
Rule	Libya	1996	only	-	Mar	30	2:00s	1:00	S
Rule	Libya	1996	only	-	Sep	30	2:00s	0	-
Rule	Libya	1997	only	-	Apr	 4	0:00	1:00	S
Rule	Libya	1997	only	-	Oct	 4	0:00	0	-
			1:00	Libya	CE%sT	1991
			2:00	-	EET	1996 Mar 30 3:00
			1:00	Libya	CE%sT	1997 Oct  4 0:00
# Shanks says DST transitions are at 0:00; go with IATA.
# From Paul Eggert (1997-10-05):
# Shanks says St Helena was 1W26 (-0:05:44) from 1890 to 1951,
# but this is most likely a typo for 5W42, the longitude of Jamestown.
# Shanks erroneously claims that most of South Africa switched to 1:00
# on 1994-04-03 at 00:00.
#
# @(#)asia	7.48
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
# Except where otherwise noted, it is the source for the data below.
# From Paul Eggert (1999-09-27):
# but usno1995 has Armenia at 4:00 (with DST), and Edgar Der-Danieliantz
# What a mess!  We guess Yerevan DST stayed in sync with Moscow between 1990
# and 1995, did not use DST in 1996, and started using DST again in 1997.
			3:00	1:00	AMST	1991 Sep 29 2:00s # Armenia Time
			3:00	-	AMT	1992 Jan 19 2:00s
			4:00 RussiaAsia	AM%sT	1996
# From Shanks (1995):
# Shanks (1995) writes that Taiwan observed DST during 1945, when it
			7:07:12	-	JMT	1924 Jan  1 0:13 # Jakarta MT
# From Shanks (1995):
Rule	Kirgiz	1991	1996	-	Sep	lastSun	0:00	0	-
			5:00	1:00	FRUST	1991 Aug 31 # independence
# From Shanks (1995):
# </a>
Rule	Mongol	1996	only	-	Oct	Fri>=22	0:00	0	-
# Transitions before 1996 are from Shanks (1995).
# IATA SSIM (1996-09) says 1997-03-31; (1998-02) says 1998-04-02;
# 2000-04-02, and 2001-04-02; ignore all these claims for now.
Rule	Syria	1994	max	-	Apr	 1	0:00	1:00	S
# From Shanks (1995), who writes ``date of change uncertain'' for 1991.
			5:00	1:00	DUSST	1991 Sep  9 # independence
			5:00 RussiaAsia	TJ%sT	1992
# From Shanks (1995):
			5:00	-	ASHT	1981 Apr  1
			5:00	1:00	ASHST	1981 Oct  1
			6:00	-	ASHT	1982 Apr  1
			5:00 RussiaAsia	ASH%sT	1991
			5:00	-	ASHT	1991 Oct 27 # independence
			5:00 RussiaAsia	TM%sT	1993	# Turkmenistan Time
# From Shanks (1995):
			5:00	-	TAST	1991 Sep  1 # independence
			5:00	-	UZT	1992
			5:00	-	TAST	1991 Sep  1 # independence
			5:00	-	UZT	1992
# From Shanks (1991):
# @(#)australasia	7.51
# Shanks gives 1917 Jan 1 0:01; go with Whitman (and guess 2:00).
Rule	Aus	1916	only	-	Oct	 1	2:00	1:00	-
			 9:30	-	CST	1917 Jan 1 0:01
			 8:00	-	WST	1917 Jan 1 0:01
			10:00	-	EST	1917 Jan 1 0:01
			10:00	-	EST	1917 Jan 1 0:01
			9:30	-	CST	1917 Jan 1 0:01
Rule	AT	1991	max	-	Oct	Sun>=1	2:00s	1:00	-
			10:00	-	EST	1917 Jan 1 0:01
			10:00	-	EST	1917 Jan 1 0:01
			10:00	-	EST	1917 Jan 1 0:01
			9:30	-	CST	1917 Jan 1 0:01
Rule	LH	1986	1989	-	Mar	Sun>=15	2:00s	0	-
Rule	LH	1990	1995	-	Mar	Sun>=1	2:00s	0	-
# From Shanks (1995):
			11:00	-	PONT	1969 Oct
			12:00	-	KOST			# Kosrae Time
# Transition time is a guess--see below
Rule	Tonga	1999	max	-	Oct	Sat>=1	0:00	1:00	S
Rule	Tonga	2000	max	-	Apr	Sat>=15	0:00	-	-
# From Paul Eggert <eggert@twinsun.com> (1999-03-22):
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
# From Paul Eggert (1996-11-22):
# Shanks gives no data for Chatham; usno1989 says it's +12:45,
# usno1995 says it's +12:45/+13:45, and IATA SSIM (1991/1996)
# Guess that they adopted DST in 1990.
# @(#)backward	7.15
# @(#)checktab.awk	1.5
				printf "%s:%d: warning:" \
# @(#)europe	7.65
# From Paul Eggert <eggert@twinsun.com> (1999-03-22):
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
# From Paul Eggert (1999-10-06):
# Presumably this was 24:00, two hours earlier than Great Britain.
# Shanks gives 1921 Mar 21 for the following transition.
# From Andrey A. Chernov <ache@astral.msk.su> (1993-11-12):
# My sources says, that it is Mar 20, not 21.
# The following transition is from Shanks's 4th edition (1995).
# Transitions before 1991 are from Shanks (1995).
			3:00	Russia	MSK/MSD	1991 Mar 31 2:00s
			2:00	-	EET	1992 Mar 29 2:00s
			2:00	1:00	EEST	1992 Sep 27 2:00s
# From Shanks (1991):
# Shanks gives 1946-10-06; go with the PTB.
# From Paul Eggert <eggert@twinsun.com> (1993-12-09):
# Reykavik was -1:28 from 1837 to 1908, local mean time before that.
			# Shanks says 1944-08-08, but
			# Riga fell to the Red Army on 1944-10-13.
			2:00	E-Eur	EE%sT
# Shanks gives 1916 May 1 0:00 and 1916 Oct 1 0:00; go with Whitman.
# Before 1937, Shanks says just `0:20'; we use Whitman's more precise figure.
			2:00	E-Eur	EE%sT
# From Shanks (1991):
# Shanks omits the first two transitions in 1940; go with Whitman.
# @(#)iso3166.tab	1.6
# From Paul Eggert <eggert@twinsun.com> (1996-09-03):
# 1.  ISO 3166-1:1997 2-character country code.  See: 
# The PS code below has been reserved for Palestine by the ISO;
# however, the code is not yet officially assigned to Palestine.  Please see
# <a href="ftp://ftp.informatik.uni-erlangen.de/pub/doc/ISO/ISO-3166-background">
# Cord Wischhoefer, Country Code Elements for Palestine (1996-07-24)
# </a>.
#
FX	France, Metropolitan
# @(#)northamerica	7.47
# From Paul Eggert <eggert@twinsun.com> (1996-11-22):
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
# The data for Canada are all from Shanks (1991).
# For what it's worth, Shanks (1995) says that Atikokan has agreed with
# Dawswon Creek uses MST.  Much of east BC is like Edmonton.
# From Paul Eggert (1996-10-07):
# Shanks's table for Watson Lake is corrupted, so we have no data there.
# The change announcement
# From Paul Eggert <eggert@twinsun.com> (1993-11-18):
# Shanks also says there are four zones, but disagrees about the fourth.
# Instead of GMT-6 with DST, he says there's GMT-8 without DST.

# From Shanks (1991):
Rule	BajaN	1950	1966	-	Apr	lastSun	2:00	1:00	D
Rule	BajaN	1950	1961	-	Sep	lastSun	2:00	0	S
Rule	BajaN	1961	1966	-	Oct	lastSun	2:00	0	S
Zone America/Cancun	-5:47:04 -	LMT	1922 Jan  1  1:12:42
Zone America/Chihuahua	-7:04:20 -	LMT	1921 Dec 31 23:55:44
# N Baja California
			-8:00	BajaN	P%sT	1967 Apr lastSun 2:00
# Baja California
Zone America/Ensenada	-7:46:28 -	LMT	1922 Jan  1  0:13:32
			-8:00	-	PST	1927 Jun 10 23:00
			-7:00	-	MST	1930 Nov 16
			-8:00	-	PST	1942 Apr
			-7:00	-	MST	1949 Jan 14
			-8:00	-	PST	1996
			-8:00	Mexico	P%sT
# Shanks gives some very odd dates for 1991, and stops there.
# For now, we won't guess further.
			-5:36	-	SJMT	1921 Jan 15 # San Jose Mean Time
			-5:30	-	HMT	1925 Jul 19 12:00 # Havana MT
# Shanks says AT is 2:00, but IATA SSIM (1991/1996) says 1:00s.  Go with IATA.
# From Shanks (1991):
			-5:00	-	EST	1974 Jan 6 2:00
# @(#)southamerica	7.31
# Thomas G. Shanks, The International Atlas (4th edition),
# San Diego: ACS Publications, Inc. (1995).
# Shanks gives 1989 Mar 16 and stops after 1990 Mar 4; go with Otero.
# From Paul Eggert (1996-11-22):
# Let's make the following assumptions:
#
# * All data in Shanks are correct through 1990.  In particular,
#   Shanks was right when he said Acre stopped observing DST in mid-1988.
# * Areas where Shanks reports DST up to 1990, but the IATA reports no DST
#   in 1995, stopped observing DST in mid-1990.
#
# Under these assumptions Brazil needs 7 entries to cover all the distinct
# time zone histories since 1970:
#
# Noronha (UTC-2), Fortaleza (UTC-3), and Manaus (UTC-4) stopped observing DST
#	in mid-1990.
# Maceio (UTC-3) stopped observing DST in mid-1990, but started again mid-1995.
# Sao Paulo (UTC-3) and Cuiaba (UTC-4) always observed DST.
# Porto Acre (UTC-5) stopped observing DST in mid-1988.

# From Rodrigo Feher <feher@pobox.com> (1998-01-17):
# Reading "southamerica" file in timezone 7.55 I've found an
# error. Line 193 say "Territory of Acre". It is not a territory anymore
# but a state.

# From Paul Eggert (1998-09-28):
# </a> (1998-09-25, in Portuguese).
# (1999-08-23), adopted by same states, says only 1999-10-03 and 2000-02-27;
# after that, these rules are guesses and are quite possibly wrong,
# but they are more likely than no DST at all.
			-2:00	Brazil	FN%sT	1990 Jul
# Amapa, east Para
			-3:00	Brazil	BR%sT	1988 Jul
# Maranhao, Piaui, Ceara, Rio Grande do Norte, Paraiba,
# Pernambuco (except Fernando de Noronha)
			-3:00	Brazil	BR%sT	1990 Jul
			-3:00	-	BRT
# Tocantins
			-3:00	Brazil	BR%sT	1990 Jul
			-3:00	-	BRT	1995 Jul
# Alagoas, Sergipe
			-3:00	Brazil	BR%sT	1990 Jul
			-3:00	-	BRT	1995 Jul
			-3:00	Brazil	BR%sT	1996 Jul
			-3:00	-	BRT
# Bahia, Goias, Distrito Federal, Minas Gerais, Espirito Santo, Rio de Janeiro,
# Sao Paulo, Parana, Santa Catarina, Rio Grande do Sul
			-3:00	-	BRST	1964
			-4:00	Brazil	AM%sT	1990 Jul
			-4:00	-	AMT
# Roraima, west Para, Rondonia
			-4:00	Brazil	AM%sT	1988 Jul
# Amazonas
			-4:00	Brazil	AM%sT	1988 Jul
			-4:00	-	AMT	1993 Jul
			-4:00	Brazil	AM%sT	1994 Jul
# Acre
			-5:00	Brazil	AC%sT	1988 Jul
# (1996-09) says 1998-03-08.  Ignore these for now.
# Shanks (1995) estimates 1993-04-03 24:00 for this; go with IATA.
# Shanks (1995) says that Bottom and Oranjestad have been at -4:00 since

# From Bob Devine (1988-01-28):
# Paraguay: First day in October to last in March.  Midnight switch??
# Since 1980.

# From U. S. Naval Observatory (1989-01-19):
# PARAGUAY            4 H  BEHIND UTC
# PARAGUAY            3 H  BEHIND UTC    OCT 1, '88-MAR 31, '89

# From Shanks (1991):
Rule	Para	1975	1978	-	Oct	 1	0:00	1:00	S
# Shanks says 1979 was all DST.
Rule	Para	1980	1991	-	Apr	 1	0:00	0	-
Rule	Para	1980	1988	-	Oct	 1	0:00	1:00	S
Rule	Para	1996	1998	-	Mar	 1	0:00	0	-
Rule	Para	1999	max	-	Feb	lastSat	0:00	0	-
# From Shanks (1991):
# Shanks's 4th edition (1995) says no DST was observed in 1990/1 and 1991/2,
# and that 1992/3's DST was from 10-25 to 03-01.  Go with IATA.
# @(#)zone.tab	1.15
BR	-0846-06354	America/Porto_Velho	W Para, Rondonia, Roraima
CN	+2217+11409	Asia/Hong_Kong	Hong Kong
MX	+2105-08646	America/Cancun	Eastern Time
MX	+1924-09909	America/Mexico_City	Central Time
MX	+3152-11637	America/Ensenada	Pacific Time - most locations
MX	+3232-11701	America/Tijuana	Pacific Time - north Baja California

Fixed code:
1999-11-09  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-load.c (_dl_dst_count): Allow $ORIGIN to point to
	directory with the reference since this is as secure as using the
	object with the dependency.
	(_dl_dst_substitute): Likewise.

	* elf/dl-load.c (_dl_dst_count): Change strings in first two
	strncmp calls to allow reuse.
	(_dl_dst_substitute): Likewise.

1999-11-01  Arnold D. Robbins  <arnold@skeeve.com>

	* posix/regex.c (init_syntax_once): move below definition of
	ISALNUM etc., then use ISALNUM to init the table, so that
	the word ops will work if i18n'ed.
	(SYNTAX): And subscript with 0xFF for 8bit character sets.

1999-11-09  Andreas Jaeger  <aj@suse.de>

	* sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin
	implementation for ttyname_r call; fix inverted condition; return
	ut_user.  Closes PR libc/1438.

1999-11-09  Ulrich Drepper  <drepper@cygnus.com>

	* timezone/checktab.awk: Update from tzcode1999h.
	* timezone/africa: Update from tzdata1999i.
	* timezone/asia: Likewise.
	* timezone/australasia: Likewise.
	* timezone/backward: Likewise.
	* timezone/europe: Likewise.
	* timezone/northamerica: Likewise.
	* timezone/southamerica: Likewise.
	* timezone/iso3166.tab: Likewise.
	* timezone/zone.tab: Likewise.

	* sysdeps/unix/sysv/linux/bits/resource.h: Define values also as
	macros.  Patch by brg@csua.berkeley.edu [PR libc/1439].

1999-11-09  Andreas Jaeger  <aj@suse.de>

	* posix/Makefile (tests): Added tst-getlogin.

	* posix/tst-getlogin.c: New file, contains simple tests for
	getlogin and getlogin_r.

1999-11-09  Andreas Schwab  <schwab@suse.de>

	* misc/syslog.c: For LOG_PERROR only append a newline if
	necessary.

  const char *const start = name;
      /* $ORIGIN is not expanded for SUID/GUID programs.

	 Note that it is no bug that the strings in the first two `strncmp'
	 calls are longer than the sequence which is actually tested.  */
      if ((((strncmp (&name[1], "ORIGIN}", 6) == 0
	     && (!__libc_enable_secure
		 || ((name[7] == '\0' || (is_path && name[7] == ':'))
		     && (name == start || (is_path && name[-1] == ':'))))
	     && (len = 7) != 0)
	    || (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
	      && ((strncmp (&name[2], "ORIGIN}", 7) == 0
		   && (!__libc_enable_secure
		       || ((name[9] == '\0' || (is_path && name[9] == ':'))
			   && (name == start || (is_path && name[-1] == ':'))))
		   && (len = 9) != 0)
  const char *const start = name;
      /* Note that it is no bug that the strings in the first two `strncmp'
	 calls are longer than the sequence which is actually tested.  */
	  if ((((strncmp (&name[1], "ORIGIN}", 6) == 0 && (len = 7) != 0)
		|| (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
		      ? (__libc_enable_secure
			 && ((name[len] != '\0'
			      && (!is_path || name[len] != ':'))
			     || (name != start
				 && (!is_path || name[-1] != ':')))
			 ? NULL : l->l_origin)
  /* Determine the number of DST elements.  */
and a pointer to the parent of the deleted node is returned by the
function.  If there is no matching entry in the tree nothing can be
deleted and the function returns @code{NULL}.  If the root of the tree
is deleted @code{tdelete} returns some unspecified value not equal to
@code{NULL}.
		/* Append a newline if necessary.  */
		if (buf[bufsize - 1] != '\n')
		  {
		    ++v;
		    v->iov_base = (char *) "\n";
		    v->iov_len = 1;
		  }
		(void)__writev(STDERR_FILENO, iov, v - iov + 1);
		   tst-preadwrite test-vfork regexbug1 tst-getlogin
#ifndef emacs
/* How many characters in the character set.  */
# define CHAR_SET_SIZE 256

# ifdef SYNTAX_TABLE

extern char *re_syntax_table;

# else /* not SYNTAX_TABLE */

static char re_syntax_table[CHAR_SET_SIZE];

static void
init_syntax_once ()
{
   register int c;
   static int done = 0;

   if (done)
     return;
   bzero (re_syntax_table, sizeof re_syntax_table);

   for (c = 0; c < CHAR_SET_SIZE; ++c)
     if (ISALNUM (c))
	re_syntax_table[c] = Sword;

   re_syntax_table['_'] = Sword;

   done = 1;
}

# endif /* not SYNTAX_TABLE */

# define SYNTAX(c) re_syntax_table[((c) & 0xFF)]

#endif /* emacs */

/* Copyright (C) 1999 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

#include <unistd.h>
#include <stdio.h>
#include <string.h>

int
main (void)
{
  char *login;
  int errors = 0;

  login = getlogin ();
  if (login == NULL)
    puts ("getlogin returned NULL, no further tests");
  else
    {
      char name[1024];
      int ret;

      printf ("getlogin returned: `%s'\n", login);

      ret = getlogin_r (name, sizeof (name));
      if (ret == 0)
	{
	  printf ("getlogin_r returned: `%s'\n", name);
	  if (strcmp (name, login) != 0)
	    {
	      puts ("Error: getlogin and getlogin_r returned different names");
	      ++errors;
	    }
	}
      else
	{
	  printf ("Error: getlogin_r returned: %d (%s)\n",
		  ret, strerror (ret));
	  ++errors;
	}
    }

  return errors != 0;
}
  /* Get name of tty connected to fd 0.  Return if not a tty or
     if fd 0 isn't open.  Note that a lot of documentation says that
     getlogin() is based on the controlling terminal---what they
     really mean is "the terminal connected to standard input".  The
     getlogin() implementation of DEC Unix, SunOS, Solaris, HP-UX all
     return NULL if fd 0 has been closed, so this is the compatible
     thing to do.  Note that ttyname(open("/dev/tty")) on those
     systems returns /dev/tty, so that is not a possible solution for
     getlogin().  */
  result = __ttyname_r (0, real_tty_path, sizeof (tty_pathname));
  
  if (result != 0)
    return result;
      size_t needed = strlen (ut->ut_user) + 1;
      if (needed > name_len)
	  memcpy (name, ut->ut_user, needed);
#define PRIO_PROCESS PRIO_PROCESS
#define PRIO_PGRP PRIO_PGRP
#define PRIO_USER PRIO_USER
# @(#)africa	7.32
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
			1:00	Libya	CE%sT	1990 May  4
# The following entries are all from Shanks;
# the IATA SSIM data contain some obvious errors.
			2:00	-	EET	1996 Sep 30
			1:00	-	CET	1997 Apr  4
			1:00	1:00	CEST	1997 Oct  4
# Shanks reports no DST after 1998-04; go with IATA.
# @(#)asia	7.49
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
# From Paul Eggert (1999-10-29):
# then to 4:00 with no DST in fall 1995, then readopting Russian DST in 1997.
# Go with Shanks, even when he disagrees with others.  Edgar Der-Danieliantz
			3:00 RussiaAsia	AM%sT	1995 Sep 24 2:00s
# From Shanks:
# Shanks writes that Taiwan observed DST during 1945, when it
# East Timor
# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
Zone	Asia/Dili	8:22:20 -	LMT	1912
			8:00	-	TPT	1942 Feb 21 23:00
			9:00	-	JST	1945 Aug
			9:00	-	TPT	1976 May  3
			8:00	-	TPT	# East Timor Time

# Shanks says the next transition was at 1924 Jan 1 0:13,
# but this must be a typo.
			7:07:12	-	JMT	1923 Dec 31 23:47:12 # Jakarta
# Shanks says Iraq did not observe DST 1992/1997 or 1999 on; ignore this.
# From Shanks:
# Transitions through 1991 are from Shanks.
Rule	Kirgiz	1992	1996	-	Sep	lastSun	0:00	0	-
			5:00	1:00	FRUST	1991 Aug 31 2:00 # independence
# From Shanks:
# IATA SSIM (1996-09) says 1996-10-25; go with Shanks.
Rule	Mongol	1996	only	-	Oct	lastSun	0:00	0	-
# IATA SSIM (1998-02) says 1998-04-02;
# 2000-04-02, and 2001-04-02; ignore all these claims and go with Shanks.
Rule	Syria	1994	1996	-	Apr	 1	0:00	1:00	S
Rule	Syria	1997	1998	-	Mar	lastMon	0:00	1:00	S
Rule	Syria	1999	max	-	Apr	 1	0:00	1:00	S
# From Shanks.
			5:00	1:00	DUSST	1991 Sep  9 2:00s
# From Shanks.
			5:00 RussiaAsia	ASH%sT	1991 Mar 31 2:00
			4:00 RussiaAsia	ASH%sT	1991 Oct 27 # independence
			4:00 RussiaAsia TM%sT	1992 Jan 19 2:00
# 1991 transitions are from Shanks.
			5:00 RussiaAsia	TAS%sT	1991 Sep  1 # independence
			5:00 RussiaAsia	UZ%sT	1992
			5:00 RussiaAsia	TAS%sT	1991 Sep  1 # independence
			5:00 RussiaAsia	UZ%sT	1992
# From Shanks:
# @(#)australasia	7.52
Rule	Aus	1917	only	-	Jan	 1	0:01	1:00	-
Rule	AT	1991	1999	-	Oct	Sun>=1	2:00s	1:00	-
Rule	AT	2000	only	-	Aug	lastSun	2:00s	1:00	-
Rule	AT	2001	max	-	Oct	Sun>=1	2:00s	1:00	-
			10:00	-	EST	1916 Oct 1 2:00
			10:00	1:00	EST	1917 Feb
Rule	LH	1986	1991	-	Mar	Sun>=15	2:00s	0	-
Rule	LH	1992	1995	-	Mar	Sun>=1	2:00s	0	-
# From Shanks:
			11:00	-	KOST	1969 Oct	# Kosrae Time
			12:00	-	KOST	1999
			11:00	-	KOST
# Shanks says the following was at 2:00; go with IATA.
Rule	Tonga	1999	max	-	Oct	Sat>=1	2:00s	1:00	S
Rule	Tonga	2000	max	-	Apr	Sun>=16	2:00s	-	-
# From Paul Eggert <eggert@twinsun.com> (1999-10-29):
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
# From Alex Livingston (1999-10-04):
# I heard on the ABC (Australian Broadcasting Corporation) radio news on the
# (long) weekend that Tasmania, which usually goes its own way in this regard,
# has decided to join with most of NSW, the ACT, and most of Victoria
# (Australia) and start daylight saving on the last Sunday in August in 2000
# instead of the first Sunday in October.

# From Paul Eggert (1999-10-29):
# Shanks gives no time data for Chatham; usno1989 says it's +12:45,
# usno1995 says it's +12:45/+13:45, and IATA SSIM (1991/1999)
# Guess that they have been in lock-step with NZ since 1990.
# From Paul Eggert (1999-10-29):
# The Federated States of Micronesia Visitors Board writes in
# <a href="http://www.fsmgov.org/info/clocks.html">
# The Federated States of Micronesia - Visitor Information
# </a> (1999-01-26)
# that Truk and Yap are GMT+10, and Ponape and Kosrae are GMT+11.
# We don't know when Kosrae switched from GMT+12; assume January 1 for now.


# From Rives McDow (1999-10-06):
# Tonga started its Daylight Saving on Saturday morning October 2nd at 0200am.
# Daylight Saving ends on April 16 at 0300am which is Sunday morning.
# @(#)backward	7.16
Link	America/Tijuana		America/Ensenada
# @(#)checktab.awk	1.6
				printf "%s:%d: warning: " \
# @(#)europe	7.66
# From Paul Eggert <eggert@twinsun.com> (1999-10-29):
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
# From Paul Eggert (1999-10-22):
# No doubt this was 24:00, two or three hours earlier than Great Britain.
# The following transition is from Shanks.
# Transitions before 1991 are from Shanks.
			3:00	Russia	MSK/MSD	1990
			3:00	-	MSK	1991 Mar 31 2:00s
			2:00	-	EET	1992 Mar 29 0:00s
			2:00	1:00	EEST	1992 Sep 27 0:00s
# From Paul Eggert <eggert@twinsun.com> (1999-10-29):
# Reykavik was 21W57 from 1837 to 1908, local mean time before that.
# see commentary for Romania
			2:00	E-Eur	EE%sT	1997
			2:00	EU	EE%sT
# Shanks gives 1916 Apr 30 24:00 and 1916 Oct 1 00:00; go with Whitman.
#
# From Paul Eggert (1999-10-07):
# <a href="http://www.nineoclock.ro/POL/1778pol.html">
# Nine O'clock</a> (1998-10-23) reports that the switch occurred at
# 04:00 local time in fall 1998.  For lack of better info,
# assume that Romania and Moldova switched to EU rules in 1997,
# the same year as Bulgaria.
#
			2:00	E-Eur	EE%sT	1997
			2:00	EU	EE%sT
# From Shanks:
# @(#)iso3166.tab	1.7
# From Paul Eggert <eggert@twinsun.com> (1999-10-13):
# 1.  ISO 3166-1:1999 2-character country code.  See:
#	<a href="http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1.html">
#	ISO 3166-1: The Code List
#	</a>.
HK	Hong Kong
# @(#)northamerica	7.48
# Wayne County, Kentucky
# From
# <a href="http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=1999_register&docid=99-26945-filed">
# Federal Register Doc. 99-26945
# </a> (1999-10-14 08:45-04)
# In response to a petition by the Wayne County, Kentucky, Fiscal Court,
# the Department of Transportation (DOT) proposed to move Wayne County,
# Kentucky, from the Central Time Zone to the Eastern Time Zone.... Now
# the earliest date that the proposed change might take effect is
# October 29, 2000.
# From Paul Eggert <eggert@twinsun.com> (1999-10-29):
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
# The data for Canada are all from Shanks.
# For what it's worth, Shanks says that Atikokan has agreed with
# Dawson Creek uses MST.  Much of east BC is like Edmonton.
# From Paul Eggert (1999-10-29):
# Nunavut moves to single time zone Oct. 31
# From Shanks:
Rule	BajaN	1954	1961	-	Apr	lastSun	2:00	1:00	D
Rule	BajaN	1954	1961	-	Sep	lastSun	2:00	0	S
Zone America/Cancun	-5:47:04 -	LMT	1922 Jan  1  0:12:56
Zone America/Chihuahua	-7:04:20 -	LMT	1921 Dec 31 23:55:40
# Baja California
			-8:00	BajaN	P%sT	1976
			-5:36:20 -	SJMT	1921 Jan 15 # San Jose Mean Time
			-5:29:36 -	HMT	1925 Jul 19 12:00 # Havana MT
# Shanks says AT is 2:00, but IATA SSIM (1991/1997) says 1:00s.  Go with IATA.
# From Shanks:
			-5:00	-	EST	1974 Apr 28 2:00
# @(#)southamerica	7.32
# Thomas G. Shanks, The International Atlas (5th edition),
# San Diego: ACS Publications, Inc. (1999).
# Shanks stops after 1992-03-01; go with Otero.
# From Paul Eggert (1998-10-29):
# </a> (1999-10-04, in Portuguese).
# (1999-08-23) adopted by same states.
# Decree <a href="http://pcdsh01.on.br/DecHV99.gif">3,188</a> (1999-09-30)
# adds SE, AL, PE, PR, RN, CE, PI, MA and RR.
# These give only one year's rules.  After that, the rules are guesses
# and are quite possibly wrong, but are more likely than no DST at all.
			-2:00	Brazil	FN%sT	1990 Sep 17
# Amapa (AP), east Para (PA)
			-3:00	Brazil	BR%sT	1988 Sep 12
# Maranhao (MA), Piaui (PI), Ceara (CE), Rio Grande do Norte (RN),
# Paraiba (PB), Pernambuco (PE) (except Fernando de Noronha)
			-3:00	Brazil	BR%sT	1990 Sep 17
			-3:00	-	BRT	1999 Sep 30
			-3:00	Brazil	BR%sT
# Tocantins (TO)
			-3:00	Brazil	BR%sT	1990 Sep 17
			-3:00	-	BRT	1995 Sep 14
# Alagoas (AL), Sergipe (SE)
			-3:00	Brazil	BR%sT	1990 Sep 17
			-3:00	-	BRT	1995 Oct 13
			-3:00	Brazil	BR%sT	1996 Sep  4
			-3:00	-	BRT	1999 Sep 30
			-3:00	Brazil	BR%sT
# Bahia (BA), Goias (GO), Distrito Federal (DF), Minas Gerais (MG),
# Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR),
# Santa Catarina (SC), Rio Grande do Sul (RS)
			-3:00	1:00	BRST	1964
			-4:00	Brazil	AM%sT
# west Para (PA), Rondonia (RO)
			-4:00	Brazil	AM%sT	1988 Sep 12
# Roraima (RR)
Zone America/Boa_Vista	-4:02:40 -	LMT	1914
			-4:00	Brazil	AM%sT	1988 Sep 12
			-4:00	-	AMT	1999 Sep 30
			-4:00	Brazil	AM%sT
#
# Amazonas (AM)
			-4:00	Brazil	AM%sT	1988 Sep 12
			-4:00	-	AMT	1993 Sep 28
			-4:00	Brazil	AM%sT	1994 Sep 22
# Acre (AC)
			-5:00	Brazil	AC%sT	1988 Sep 12
# (1996-09) says 1998-03-08.  Ignore these.
# Shanks specifies 24:00 for 1992 transition times; go with IATA,
# as it seems implausible to change clocks at midnight New Year's Eve.
# Shanks says that Bottom and Oranjestad have been at -4:00 since
# From Paul Eggert (1999-10-29):
# Shanks (1999) says that spring transitions are from 01:00 -> 02:00,
# and autumn transitions are from 00:00 -> 23:00.  Go with earlier
# editions of Shanks, and with the IATA, who say transitions occur at 00:00.
Rule	Para	1975	1988	-	Oct	 1	0:00	1:00	S
Rule	Para	1979	1991	-	Apr	 1	0:00	0	-
Rule	Para	1996	only	-	Mar	 1	0:00	0	-
# IATA SSIM (1997-09) says Mar 1; go with Shanks.
Rule	Para	1997	only	-	Feb	lastSun	0:00	0	-
Rule	Para	1998	only	-	Mar	 1	0:00	0	-
# IATA SSIM (1999-02) says lastSat, not lastSun; go with Shanks.
Rule	Para	1999	max	-	Feb	lastSun	0:00	0	-
# From Shanks:
# Shanks says no DST was observed in 1990/1 and 1991/2,
# and that 1992/3's DST was from 10-25 to 03-01.  Go with IATA.
# @(#)zone.tab	1.16
BR	-0846-06354	America/Porto_Velho	W Para, Rondonia
BR	+0249-06040	America/Boa_Vista	Roraima
HK	+2217+11409	Asia/Hong_Kong
MX	+1924-09909	America/Mexico_City	Central Time - most locations
MX	+2105-08646	America/Cancun	Central Time - Quintana Roo
MX	+3232-11701	America/Tijuana	Pacific Time
TP	-0833+12535	Asia/Dili