[tz] localtime crash and fix

Alois Treindl alois at astro.ch
Thu Nov 23 18:32:25 UTC 2023


I have observed occasional crashes in localtime.c in the current github 
version.

In one of my applications, localtime() is called multiple times for 
several zones.

The condition when the segmentation fault appears are herd to reproduce 
or demonstrate.

This patch in function tzload() however solves the issue:

--- localtime.c    2023-11-16 20:18:01.904577574 +0100
+++ a/localtime.c    2023-11-23 19:22:21.062249899 +0100
@@ -769,6 +769,7 @@
    }
  #else
    union local_storage ls;
+  memset(&ls, 0, sizeof(ls));
    return tzloadbody(name, sp, doextend, &ls);
  #endif
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mm.icann.org/pipermail/tz/attachments/20231123/6111aa8a/attachment.html>
-------------- next part --------------
--- localtime.c	2023-11-16 20:18:01.904577574 +0100
+++ a/localtime.c	2023-11-23 19:22:21.062249899 +0100
@@ -769,6 +769,7 @@
   }
 #else
   union local_storage ls;
+  memset(&ls, 0, sizeof(ls));
   return tzloadbody(name, sp, doextend, &ls);
 #endif
 }


More information about the tz mailing list