tst-tzset: output reason when creating 4GiB file fails

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.
This commit is contained in:
Stafford Horne 2021-09-20 06:03:07 +09:00
parent d672a98a1a
commit afbf26492a

View 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");