about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
Diffstat (limited to 'time')
-rw-r--r--time/Makefile16
-rw-r--r--time/tzfile.c24
-rw-r--r--time/tzset.c14
3 files changed, 34 insertions, 20 deletions
diff --git a/time/Makefile b/time/Makefile
index b994eee1ac..08a19a1838 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -35,11 +35,7 @@ routines	:= offtime asctime clock ctime ctime_r difftime	\
 		   strptime
 
 others	:= ap zdump zic
-tests	:= test_time clocktest test-tz
-
-# Before the test-tz test can be run we need the data to be installed.
-tests: install-test-data
-
+tests	:= test_time clocktest
 
 tzfiles := africa antarctica asia australasia europe northamerica \
 	   southamerica etcetera factory systemv backward \
@@ -56,6 +52,15 @@ all: # Make this the default target; it will be defined in Rules.
 
 include ../Makeconfig	# Get objpfx defined so we can use it below.
 
+ifeq (no,$(cross-compiling))
+# We can run the test-tz test only if we can install the test data using
+# zic.  This isn't possible when cross-compiling.
+tests += test-tz
+
+# Before the test-tz test can be run we need the data to be installed.
+tests: install-test-data
+endif
+
 # z.* use this variable.
 define nl
 
@@ -158,6 +163,7 @@ CFLAGS-zic.c = -Wno-strict-prototypes -DNOID $(tz-cflags)
 CFLAGS-ialloc.c = -Wno-strict-prototypes -DNOID
 CFLAGS-scheck.c = -Wno-strict-prototypes -DNOID
 CFLAGS-tzfile.c = $(tz-cflags)
+CFLAGS-tzset.c = $(tz-cflags)
 
 # We have to make sure the data for testing the tz functions is available.
 .PHONY: install-test-data
diff --git a/time/tzfile.c b/time/tzfile.c
index ed7b0932f3..e063d5d04f 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -112,17 +112,19 @@ __tzfile_read (const char *file)
   else if (*file == '\0')
     /* User specified the empty string; use UTC explicitly.  */
     file = "Universal";
-
-  /* We must not allow to read an arbitrary file in a setuid program.
-     So we fail for any file which is not in the directory hierachy
-     starting at TZDIR.  */
-  if (__libc_enable_secure
-      && ((*file == '/'
-	   && memcmp (file, default_tzdir, sizeof (default_tzdir) - 1) != 0)
-	  || strstr (file, "../") != NULL))
-    /* This test a certainly a bit too restrictive but it should catch all
-       critical case.  */
-    return;
+  else
+    {
+      /* We must not allow to read an arbitrary file in a setuid
+	 program.  So we fail for any file which is not in the
+	 directory hierachy starting at TZDIR.  */
+      if (__libc_enable_secure
+	  && ((*file == '/'
+	       && memcmp (file, default_tzdir, sizeof (default_tzdir) - 1))
+	      || strstr (file, "../") != NULL))
+	/* This test a certainly a bit too restrictive but it should
+	   catch all critical case.  */
+	return;
+    }
 
   if (*file != '/')
     {
diff --git a/time/tzset.c b/time/tzset.c
index 87dc6d6337..05760b2c62 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -94,6 +94,12 @@ __tzset_internal (always)
 
   /* Examine the TZ environment variable.  */
   tz = getenv ("TZ");
+  if (tz == NULL)
+    /* No user specification; use the site-wide default.  */
+    tz = TZDEFAULT;
+  else if (*tz == '\0')
+    /* User specified the empty string; use UTC explicitly.  */
+    tz = "Universal";
 
   /* A leading colon means "implementation defined syntax".
      We ignore the colon and always use the same algorithm:
@@ -108,10 +114,10 @@ __tzset_internal (always)
 
   /* Free old storage.  */
   if (tz_rules[0].name != NULL && *tz_rules[0].name != '\0')
-    free((void *) tz_rules[0].name);
+    free ((void *) tz_rules[0].name);
   if (tz_rules[1].name != NULL && *tz_rules[1].name != '\0' &&
       tz_rules[1].name != tz_rules[0].name)
-    free((void *) tz_rules[1].name);
+    free ((void *) tz_rules[1].name);
   tz_rules[0].name = NULL;
   tz_rules[1].name = NULL;
 
@@ -163,7 +169,7 @@ __tzset_internal (always)
       return;
     }
 
-  if (sscanf(tz, "%[^0-9,+-]", tz_rules[0].name) != 1 ||
+  if (sscanf (tz, "%[^0-9,+-]", tz_rules[0].name) != 1 ||
       (l = strlen(tz_rules[0].name)) < 3)
     {
       free (tz_rules[0].name);
@@ -180,7 +186,7 @@ __tzset_internal (always)
   tz += l;
 
   /* Figure out the standard offset from UTC.  */
-  if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit(*tz)))
+  if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz)))
     return;
 
   if (*tz == '-' || *tz == '+')