]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Initialize tzcode early.
authorDag-Erling Smørgrav <[email protected]>
Sat, 16 Sep 2023 09:02:46 +0000 (11:02 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 20 Nov 2023 08:04:09 +0000 (09:04 +0100)
An explicit tzset() call is usually not needed as it happens implicitly
the first time we call localtime() or mktime(), but in some cases
(sandboxing, chroot) this may be too late.

(cherry picked from commit 54d5fbec2c52d2e04cb549caa0a811ab1da5aa56)

tcpdump.c

index 633d4812d0e5379f41f5542705aa4f1ea34c80cb..a6ee95b96f01b5887d56b0d9ea22e947619f01d5 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1560,6 +1560,13 @@ main(int argc, char **argv)
        if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
                error("%s", ebuf);
 
+       /*
+        * An explicit tzset() call is usually not needed as it happens
+        * implicitly the first time we call localtime() or mktime(),
+        * but in some cases (sandboxing, chroot) this may be too late.
+        */
+       tzset();
+
        while (
            (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1)
                switch (op) {