]> 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)
committerfxlb <[email protected]>
Mon, 20 Nov 2023 07:52:52 +0000 (07:52 +0000)
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.

tcpdump.c

index a7a97fffef1bc2b6b597ed5e428c68a3c2a01f8f..a7756be5624c0322d403c7b56403da6601509dc6 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1575,6 +1575,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) {