about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-11 19:26:20 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-11 19:26:20 +0000
commit640b76b7dc0bd8a5263d001b7d4f2024dafb70bb (patch)
tree1e0e37d5f72293e63804a8d1dbf6d4788db1a8e5 /time
parentc3d1af70af685c68c8dfcebd3121062d25cc5c69 (diff)
downloadglibc-640b76b7dc0bd8a5263d001b7d4f2024dafb70bb.tar.gz
glibc-640b76b7dc0bd8a5263d001b7d4f2024dafb70bb.tar.xz
glibc-640b76b7dc0bd8a5263d001b7d4f2024dafb70bb.zip
Update.
2004-08-11  Ulrich Drepper  <drepper@redhat.com>

	* time/tzset.c (tzset_internal): Add new parameter which is
	nonzero if called through tzset.  Use TZDEFAULT name including
	name comparison if the new parameter is zero.  This means implicit
	tzset calls will not cause files to be opened and read by tzfile.c
	all the time.

2004-08-11  Jakub Jelinek  <jakub@redhat.com>

	* time/tzfile.c (__tzfile_read): Free transitions only if it will
	not be reused.
Diffstat (limited to 'time')
-rw-r--r--time/tzfile.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/time/tzfile.c b/time/tzfile.c
index b118e07dc4..8c2756e7bb 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -104,16 +104,12 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
 
   __use_tzfile = 0;
 
-  if (transitions != NULL)
-    free ((void *) transitions);
-  transitions = NULL;
-
   if (file == NULL)
     /* No user specification; use the site-wide default.  */
     file = TZDEFAULT;
   else if (*file == '\0')
     /* User specified the empty string; use UTC with no leap seconds.  */
-    return;
+    goto ret_free_transitions;
   else
     {
       /* We must not allow to read an arbitrary file in a setuid
@@ -127,7 +123,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
 	      || strstr (file, "../") != NULL))
 	/* This test is certainly a bit too restrictive but it should
 	   catch all critical cases.  */
-	return;
+	goto ret_free_transitions;
     }
 
   if (*file != '/')
@@ -156,14 +152,14 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
      disabled.  */
   f = fopen (file, "rc");
   if (f == NULL)
-    return;
+    goto ret_free_transitions;
 
   /* Get information about the file.  */
   struct stat64 st;
   if (fstat64 (fileno (f), &st) != 0)
     {
       fclose (f);
-      return;
+      goto ret_free_transitions;
     }
   if (was_using_tzfile && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev)
     {
@@ -173,6 +169,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
       return;
     }
 
+  free ((void *) transitions);
+  transitions = NULL;
+
   /* Remember the inode and device number.  */
   tzfile_dev = st.st_dev;
   tzfile_ino = st.st_ino;
@@ -381,6 +380,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
 
  lose:
   fclose (f);
+ ret_free_transitions:
+  free ((void *) transitions);
+  transitions = NULL;
 }
 
 /* The user specified a hand-made timezone, but not its DST rules.