Blame SOURCES/glibc-rh1234449-1.patch

147e83
commit 45c30c61c9001867c1891f5862764f084e53f348
147e83
Author: Ondřej Bílka <neleai@seznam.cz>
147e83
Date:   Sun Oct 20 08:25:25 2013 +0200
147e83
147e83
    Replace alloca in __tzfile_read by malloc. Fixes bug 15670
147e83
147e83
diff --git a/time/tzfile.c b/time/tzfile.c
147e83
index 9dd5130..3ea3051 100644
147e83
--- a/time/tzfile.c
147e83
+++ b/time/tzfile.c
147e83
@@ -114,6 +114,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
147e83
   int was_using_tzfile = __use_tzfile;
147e83
   int trans_width = 4;
147e83
   size_t tzspec_len;
147e83
+  char *new = NULL;
147e83
 
147e83
   if (sizeof (time_t) != 4 && sizeof (time_t) != 8)
147e83
     abort ();
147e83
@@ -145,22 +146,12 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
147e83
   if (*file != '/')
147e83
     {
147e83
       const char *tzdir;
147e83
-      unsigned int len, tzdir_len;
147e83
-      char *new, *tmp;
147e83
 
147e83
       tzdir = getenv ("TZDIR");
147e83
       if (tzdir == NULL || *tzdir == '\0')
147e83
-	{
147e83
-	  tzdir = default_tzdir;
147e83
-	  tzdir_len = sizeof (default_tzdir) - 1;
147e83
-	}
147e83
-      else
147e83
-	tzdir_len = strlen (tzdir);
147e83
-      len = strlen (file) + 1;
147e83
-      new = (char *) __alloca (tzdir_len + 1 + len);
147e83
-      tmp = __mempcpy (new, tzdir, tzdir_len);
147e83
-      *tmp++ = '/';
147e83
-      memcpy (tmp, file, len);
147e83
+	tzdir = default_tzdir;
147e83
+      if (__asprintf (&new, "%s/%s", tzdir, file) == -1)
147e83
+	goto ret_free_transitions;
147e83
       file = new;
147e83
     }
147e83
 
147e83
@@ -170,11 +161,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
147e83
       && stat64 (file, &st) == 0
147e83
       && tzfile_ino == st.st_ino && tzfile_dev == st.st_dev
147e83
       && tzfile_mtime == st.st_mtime)
147e83
-    {
147e83
-      /* Nothing to do.  */
147e83
-      __use_tzfile = 1;
147e83
-      return;
147e83
-    }
147e83
+    goto done;  /* Nothing to do.  */
147e83
 
147e83
   /* Note the file is opened with cancellation in the I/O functions
147e83
      disabled and if available FD_CLOEXEC set.  */
147e83
@@ -527,12 +514,15 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
147e83
   __daylight = rule_stdoff != rule_dstoff;
147e83
   __timezone = -rule_stdoff;
147e83
 
147e83
+ done:
147e83
   __use_tzfile = 1;
147e83
+  free (new);
147e83
   return;
147e83
 
147e83
  lose:
147e83
   fclose (f);
147e83
  ret_free_transitions:
147e83
+  free (new);
147e83
   free ((void *) transitions);
147e83
   transitions = NULL;
147e83
 }