]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
timezone: Remove TZNAME_MAX limit from sysconf [BZ #15576]
authorFlorian Weimer <fweimer@redhat.com>
Tue, 7 Mar 2017 08:37:46 +0000 (09:37 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 7 Mar 2017 16:45:38 +0000 (17:45 +0100)
glibc does not impose a limit, and POSIX does not allow a
sysconf limit which changes during the lifetime of a process.

ChangeLog
include/time.h
manual/conf.texi
posix/sysconf.c
sysdeps/posix/sysconf.c
time/tzfile.c
time/tzset.c

index 340ae0ee72597baebd5ea94f77cf297e5dea1d3d..63b9a15b2bec9fcdced80e97b685e11667b2e036 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2017-03-07  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #15576]
+       Remove TZNAME_MAX limit from sysconf.
+       * include/time.h (__tzname_cur_max, __tzname_max): Remove
+       declaration.
+       * time/tzfile.c (__tzfile_read, __tzfile_default): Do not call
+       compute_tzname_max.
+       (compute_tzname_max): Remove.
+       * time/tzset.c (__tzname_cur_max, __tzname_max): Remove.
+       (update_vars): Do not update __tzname_cur_max.
+       (tzset_internal): Remove argument.
+       (__tzset): Adjust call to tzset_internal.
+       (__tz_convert): Likewise.
+       * posix/sysconf.c (__sysconf): Return -1 for _SC_TZNAME_MAX.
+       * sysdeps/posix/sysconf.c (__sysconf): Likewise.
+       * manual/conf.texi (Sysconf Definition): Update comment.
+
 2017-03-07  Siddhesh Poyarekar  <siddhesh@sourceware.org>
 
        [BZ #21209]
index 684ceb812fa8228c6759ee2588afd255fde55d5e..6badf0e5578b0c23a0b4d154aff7a50ea01affa3 100644 (file)
@@ -37,10 +37,6 @@ extern struct tm _tmbuf attribute_hidden;
 /* Defined in tzset.c.  */
 extern char *__tzstring (const char *string);
 
-/* Defined in tzset.c. */
-extern size_t __tzname_cur_max attribute_hidden;
-
-
 extern int __use_tzfile attribute_hidden;
 
 extern void __tzfile_read (const char *file, size_t extra,
@@ -82,10 +78,6 @@ extern void __tzset (void);
 /* Prototype for the internal function to get information based on TZ.  */
 extern struct tm *__tz_convert (const time_t *timer, int use_localtime, struct tm *tp);
 
-/* Return the maximum length of a timezone name.
-   This is what `sysconf (_SC_TZNAME_MAX)' does.  */
-extern long int __tzname_max (void);
-
 extern int __nanosleep (const struct timespec *__requested_time,
                        struct timespec *__remaining);
 libc_hidden_proto (__nanosleep)
index 78b7a4d01a29ab9d7ed13762331cfc6ed1bb2256..1fe75c293f59ba278a873f33159ddc2bf1e65553 100644 (file)
@@ -291,14 +291,10 @@ constants are declared in the header file @file{unistd.h}.
 @safety{@prelim{}@mtsafe{@mtsenv{}}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsmem{} @acsfd{}}}
 @c Some parts of the implementation open /proc and /sys files and dirs
 @c to collect system details, using fd and stream I/O depending on the
-@c case.  _SC_TZNAME_MAX calls __tzname_max, that (while holding a lock)
-@c calls tzset_internal, that calls getenv if it's called the first
-@c time; there are free and strdup calls in there too.  The returned max
-@c value may change over time for TZNAME_MAX, depending on selected
-@c timezones; NPROCS, NPROCS_CONF, PHYS_PAGES, AVPHYS_PAGES,
-@c NGROUPS_MAX, SIGQUEUE_MAX, depending on variable values read from
-@c /proc at each call, and from rlimit-obtained values CHILD_MAX,
-@c OPEN_MAX, ARG_MAX, SIGQUEUE_MAX.
+@c case.  The returned max value may change over time for NPROCS,
+@c NPROCS_CONF, PHYS_PAGES, AVPHYS_PAGES, NGROUPS_MAX, SIGQUEUE_MAX,
+@c depending on variable values read from /proc at each call, and from
+@c rlimit-obtained values CHILD_MAX, OPEN_MAX, ARG_MAX, SIGQUEUE_MAX.
 This function is used to inquire about runtime system parameters.  The
 @var{parameter} argument should be one of the @samp{_SC_} symbols listed
 below.
index 0b73b6a2c537c01313207ec990232076ce6f1141..4e9ed9705fd08251b4b472cbf6f089a0b401b4b1 100644 (file)
@@ -37,7 +37,7 @@ __sysconf (int name)
       return -1;
 
     case _SC_TZNAME_MAX:
-      return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
+      return -1;
 
     case _SC_CHARCLASS_NAME_MAX:
 #ifdef CHARCLASS_NAME_MAX
index 19ed5b0ce7a3223e374a6c8be353d6f5e8f07a20..a95e1b3f055ace6d6efcc5b6f97599957481fb49 100644 (file)
@@ -93,7 +93,7 @@ __sysconf (int name)
 #endif
 
     case _SC_TZNAME_MAX:
-      return MAX (__tzname_max (), _POSIX_TZNAME_MAX);
+      return -1;
 
     case _SC_JOB_CONTROL:
 #if CONF_IS_DEFINED_SET (_POSIX_JOB_CONTROL)
index 4987f1a59b5f2afd69a88d5d3b512d1c2a09e9ba..d41246980bf5ebb07549e50d07d6d6ec89f3b794 100644 (file)
@@ -48,8 +48,6 @@ struct leap
     long int change;           /* Seconds of correction to apply.  */
   };
 
-static void compute_tzname_max (size_t) internal_function;
-
 static size_t num_transitions;
 libc_freeres_ptr (static time_t *transitions);
 static unsigned char *type_idxs;
@@ -494,8 +492,6 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
   if (__tzname[1] == NULL)
     __tzname[1] = __tzname[0];
 
-  compute_tzname_max (chars);
-
   if (num_transitions == 0)
     /* Use the first rule (which should also be the only one).  */
     rule_stdoff = rule_dstoff = types[0].offset;
@@ -626,8 +622,6 @@ __tzfile_default (const char *std, const char *dst,
   /* Set the timezone.  */
   __timezone = -types[0].offset;
 
-  compute_tzname_max (stdlen + dstlen);
-
   /* Invalidate the tzfile attribute cache to force rereading
      TZDEFRULES the next time it is used.  */
   tzfile_dev = 0;
@@ -836,21 +830,3 @@ __tzfile_compute (time_t timer, int use_localtime,
        }
     }
 }
-\f
-static void
-internal_function
-compute_tzname_max (size_t chars)
-{
-  const char *p;
-
-  p = zone_names;
-  do
-    {
-      const char *start = p;
-      while (*p != '\0')
-       ++p;
-      if ((size_t) (p - start) > __tzname_cur_max)
-       __tzname_cur_max = p - start;
-    }
-  while (++p < &zone_names[chars]);
-}
index 262bbe5ef967897b7cdd9bea6609156b6fb20313..f0e5c95e829ef64f2e9e4971f57e21d933355e24 100644 (file)
@@ -68,8 +68,7 @@ static tz_rule tz_rules[2];
 
 
 static void compute_change (tz_rule *rule, int year) __THROW internal_function;
-static void tzset_internal (int always, int explicit)
-     __THROW internal_function;
+static void tzset_internal (int always);
 \f
 /* List of buffers containing time zone strings. */
 struct tzstring_l
@@ -126,24 +125,7 @@ __tzstring (const char *s)
 {
   return __tzstring_len (s, strlen (s));
 }
-\f
-/* Maximum length of a timezone name.  tzset_internal keeps this up to date
-   (never decreasing it) when ! __use_tzfile.
-   tzfile.c keeps it up to date when __use_tzfile.  */
-size_t __tzname_cur_max;
-
-long int
-__tzname_max (void)
-{
-  __libc_lock_lock (tzset_lock);
-
-  tzset_internal (0, 0);
-
-  __libc_lock_unlock (tzset_lock);
 
-  return __tzname_cur_max;
-}
-\f
 static char *old_tz;
 
 static void
@@ -154,14 +136,6 @@ update_vars (void)
   __timezone = -tz_rules[0].offset;
   __tzname[0] = (char *) tz_rules[0].name;
   __tzname[1] = (char *) tz_rules[1].name;
-
-  /* Keep __tzname_cur_max up to date.  */
-  size_t len0 = strlen (__tzname[0]);
-  size_t len1 = strlen (__tzname[1]);
-  if (len0 > __tzname_cur_max)
-    __tzname_cur_max = len0;
-  if (len1 > __tzname_cur_max)
-    __tzname_cur_max = len1;
 }
 
 
@@ -390,8 +364,7 @@ __tzset_parse_tz (const char *tz)
 
 /* Interpret the TZ envariable.  */
 static void
-internal_function
-tzset_internal (int always, int explicit)
+tzset_internal (int always)
 {
   static int is_initialized;
   const char *tz;
@@ -402,12 +375,6 @@ tzset_internal (int always, int explicit)
 
   /* Examine the TZ environment variable.  */
   tz = getenv ("TZ");
-  if (tz == NULL && !explicit)
-    /* Use the site-wide default.  This is a file name which means we
-       would not see changes to the file if we compare only the file
-       name for change.  We want to notice file changes if tzset() has
-       been called explicitly.  Leave TZ as NULL in this case.  */
-    tz = TZDEFAULT;
   if (tz && *tz == '\0')
     /* User specified the empty string; use UTC explicitly.  */
     tz = "Universal";
@@ -583,7 +550,7 @@ __tzset (void)
 {
   __libc_lock_lock (tzset_lock);
 
-  tzset_internal (1, 1);
+  tzset_internal (1);
 
   if (!__use_tzfile)
     {
@@ -615,7 +582,7 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp)
   /* Update internal database according to current TZ setting.
      POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname.
      This is a good idea since this allows at least a bit more parallelism.  */
-  tzset_internal (tp == &_tmbuf && use_localtime, 1);
+  tzset_internal (tp == &_tmbuf && use_localtime);
 
   if (__use_tzfile)
     __tzfile_compute (*timer, use_localtime, &leap_correction,