]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
tst-tzset: output reason when creating 4GiB file fails
authorStafford Horne <shorne@gmail.com>
Sun, 19 Sep 2021 21:03:07 +0000 (06:03 +0900)
committerStafford Horne <shorne@gmail.com>
Fri, 12 Nov 2021 23:08:47 +0000 (08:08 +0900)
Currently, if the temporary file creation fails the create_tz_file
function returns NULL.  The NULL pointer is then passed to setenv which
causes a SIGSEGV.  Rather than failing with a SIGSEGV print a warning
and exit.

timezone/tst-tzset.c

index d6da2932bb3c6936f591b75ae647df3bf546d380..3dad42e041251edcd89ba226db6ac76b5566108a 100644 (file)
@@ -25,6 +25,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <support/check.h>
+#include <inttypes.h>
 
 static int do_test (void);
 #define TEST_FUNCTION do_test ()
@@ -103,6 +104,13 @@ static void
 test_tz_file (off64_t size)
 {
   char *path = create_tz_file (size);
+  if (path == NULL)
+   {
+     printf ("creating timezone file of size: %" PRId64 "MiB failed.\n",
+            size / (1024 * 1024));
+     exit (1);
+   }
+
   if (setenv ("TZ", path, 1) < 0)
     {
       printf ("setenv failed: %m\n");