X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/262e119454d1e6e2121435cba3c47f34dbac0df4..5ee91ef4b64a56003edc9535f6445d3bba1fdffd:/tcpdump.c diff --git a/tcpdump.c b/tcpdump.c index a7a97fff..7159d1c7 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -997,7 +997,7 @@ tstamp_precision_to_string(int precision) * that requires that it be able to do an F_GETFL fcntl() to read * the O_ flags. * - * Tcpdump uses ftell() to determine how much data has been written + * tcpdump uses ftell() to determine how much data has been written * to a file in order to, when used with -C, determine when it's time * to rotate capture files. ftell() therefore needs to do an lseek() * to find out the file offset and must, thanks to the aforementioned @@ -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) { @@ -2319,8 +2326,11 @@ main(int argc, char **argv) * on; this may be a non-Linux "any" device * that doesn't support DLT_LINUX_SLL2. */ - if (strcmp(device, "any") == 0) + if (strcmp(device, "any") == 0) { +DIAG_OFF_WARN_UNUSED_RESULT (void) pcap_set_datalink(pd, DLT_LINUX_SLL2); +DIAG_ON_WARN_UNUSED_RESULT + } } #endif i = pcap_snapshot(pd); @@ -2387,7 +2397,7 @@ main(int argc, char **argv) * devices, and can't just give users that permission, * you'd make tcpdump set-UID or set-GID). * - * Tcpdump doesn't necessarily write only to one savefile; + * tcpdump doesn't necessarily write only to one savefile; * the general only way to allow a -Z instance to write to * savefiles as the user under whose UID it's run, rather * than as the user specified with -Z, would thus be to switch