[Bug 2030684] Re: tzname[1] empty after tzset() with env TZ="UTC"

Athos Ribeiro 2030684 at bugs.launchpad.net
Mon Aug 14 18:38:05 UTC 2023


PHP carries a patch (in debian) to allow the interpreter to use the
symtem's tzdata. This issue triggered a (until now) concealed issue
which leads to a null pointer deref.

While the latest tzdata upload fixes the issue in PHP, it should be nice
to re-visit that PHP patch to ensure that it either falls back to the
php internal tz data db or to make php fail gracefully when there are
inconsistencies between the hardcoded assumptions (e.g., setting a
default to UTC when no data is found) and the actual tzdata in the
system (e.g., the UTC value set as default is not available in the
system).

I am adding this bug to the server team backlog so we can re-visit the
patch when time allows. Once the other components are fixed, we should
remove the update-excuse tag from this bug.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/2030684

Title:
  tzname[1] empty after tzset() with env TZ="UTC"

Status in django-mailman3 package in Ubuntu:
  New
Status in php8.2 package in Ubuntu:
  Triaged
Status in postgresql-15 package in Ubuntu:
  Fix Committed
Status in python-django package in Ubuntu:
  New
Status in systemd package in Ubuntu:
  New
Status in tzdata package in Ubuntu:
  Fix Committed
Status in tzdata package in Debian:
  Unknown

Bug description:
  The following program prints different output when run with tzdata
  2023c-7ubuntu1 from mantic, versus tzdata 2023c-8ubuntu1 from mantic-
  proposed:

  root at mantic:~# cat bug.c 
  #include <errno.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <time.h>

  int main(void) {
          int r;

          r = setenv("TZ", ":UTC", 1);
          if (r < 0) {
                  printf("Failed to set TZ env var: %s\n", strerror(errno));
                  return 1;
          }

          tzset();

          printf("timezone = %lu, daylight = %d\n", timezone, daylight);
          printf("tzname[0] = %s, tzname[1] = %s\n", tzname[0], tzname[1]);
  }

  root at mantic:~# gcc bug.c
  root at mantic:~# ./a.out 
  timezone = 0, daylight = 0
  tzname[0] = UTC, tzname[1] = UTC
  root at mantic:~# apt-cache policy tzdata
  tzdata:
    Installed: 2023c-7ubuntu1
    Candidate: 2023c-7ubuntu1
    Version table:
   *** 2023c-7ubuntu1 500
          500 http://archive.ubuntu.com/ubuntu mantic/main amd64 Packages
          100 /var/lib/dpkg/status

  If I install tzdata from mantic-proposed, I get different output:

  root at mantic:~# vi /etc/apt/sources.list
  root at mantic:~# apt update && apt install tzdata
  Hit:1 http://archive.ubuntu.com/ubuntu mantic InRelease
  Hit:2 http://security.ubuntu.com/ubuntu mantic-security InRelease
  Get:3 http://archive.ubuntu.com/ubuntu mantic-proposed InRelease [118 kB]
  Hit:4 http://archive.ubuntu.com/ubuntu mantic-updates InRelease
  Hit:5 http://archive.ubuntu.com/ubuntu mantic-backports InRelease
  Get:6 http://archive.ubuntu.com/ubuntu mantic-proposed/main amd64 Packages [35.9 kB]
  Get:7 http://archive.ubuntu.com/ubuntu mantic-proposed/main Translation-en [14.8 kB]
  Get:8 http://archive.ubuntu.com/ubuntu mantic-proposed/main amd64 DEP-11 Metadata [2376 B]
  Get:9 http://archive.ubuntu.com/ubuntu mantic-proposed/main amd64 c-n-f Metadata [1004 B]
  Get:10 http://archive.ubuntu.com/ubuntu mantic-proposed/restricted amd64 Packages [15.9 kB]
  Get:11 http://archive.ubuntu.com/ubuntu mantic-proposed/restricted Translation-en [3564 B]
  Get:12 http://archive.ubuntu.com/ubuntu mantic-proposed/restricted amd64 c-n-f Metadata [336 B]
  Fetched 192 kB in 1s (324 kB/s)                                     
  Reading package lists... Done
  Building dependency tree... Done
  Reading state information... Done
  72 packages can be upgraded. Run 'apt list --upgradable' to see them.
  root at mantic:~# apt install tzdata=2023c-8ubuntu1
  Reading package lists... Done
  Building dependency tree... Done
  Reading state information... Done
  The following packages were automatically installed and are no longer required:
    libefiboot1 libefivar1
  Use 'apt autoremove' to remove them.
  The following packages will be upgraded:
    tzdata
  1 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.
  Need to get 269 kB of archives.
  After this operation, 142 kB disk space will be freed.
  Get:1 http://archive.ubuntu.com/ubuntu mantic-proposed/main amd64 tzdata all 2023c-8ubuntu1 [269 kB]
  Fetched 269 kB in 0s (867 kB/s)
  Preconfiguring packages ...
  (Reading database ... 39935 files and directories currently installed.)
  Preparing to unpack .../tzdata_2023c-8ubuntu1_all.deb ...
  Unpacking tzdata (2023c-8ubuntu1) over (2023c-7ubuntu1) ...
  Setting up tzdata (2023c-8ubuntu1) ...

  Current default time zone: 'Etc/UTC'
  Local time is now:      Mon Aug  7 21:18:35 UTC 2023.
  Universal Time is now:  Mon Aug  7 21:18:35 UTC 2023.
  Run 'dpkg-reconfigure tzdata' if you wish to change it.

  Scanning processes...                                                                                                                                                                                                                          
  Scanning candidates...                                                                                                                                                                                                                         

  Restarting services...
  Service restarts being deferred:
   systemctl restart systemd-logind.service
   systemctl restart unattended-upgrades.service

  No containers need to be restarted.

  No user sessions are running outdated binaries.

  No VM guests are running outdated hypervisor (qemu) binaries on this
  host.

  root at mantic:~# ./a.out 
  timezone = 0, daylight = 0
  tzname[0] = UTC, tzname[1] = 
  root at mantic:~# apt-cache policy tzdata-legacy
  tzdata-legacy:
    Installed: (none)
    Candidate: 2023c-7ubuntu1
    Version table:
       2023c-8ubuntu1 100
          100 http://archive.ubuntu.com/ubuntu mantic-proposed/main amd64 Packages
       2023c-7ubuntu1 500
          500 http://archive.ubuntu.com/ubuntu mantic/main amd64 Packages

  In particular, note that tzname[1] (the name of the daylight zone) is
  empty, whereas it previously printed "UTC".

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/django-mailman3/+bug/2030684/+subscriptions




More information about the foundations-bugs mailing list