On Fri, May 10, 2019 at 03:25:17PM +0200, Holger Mikolon wrote:
> The comment above priv_localtime() says, the obtained localtime (from the
> privileged process) is cached for about one minute. However, since the
> according if statement compares the wrong variable, the caching doesn't
> happen. This bug is there since the very first file version (from 15+
> years ago).
>
> Regards
> Holger
No, this is not correct.
The point is that the code remembers the timezone corrected value so
it does not have to consult the privileged process for it all the time.
Once the timezone corrected date and hour and mintue are known, only
seconds are updated via a call to gmtime().
-Otto
>
>
> Index: usr.sbin/tcpdump/privsep.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/tcpdump/privsep.c,v
> retrieving revision 1.53
> diff -u -p -u -r1.53 privsep.c
> --- usr.sbin/tcpdump/privsep.c 18 Mar 2019 00:09:22 -0000 1.53
> +++ usr.sbin/tcpdump/privsep.c 10 May 2019 13:17:42 -0000
> @@ -727,7 +727,7 @@ priv_localtime(const time_t *t)
> static struct tm *gt = NULL;
> static char zone[PATH_MAX];
>
> - if (gt != NULL) {
> + if (t != NULL) {
> gt = gmtime(t);
> gt0.tm_sec = gt->tm_sec;
> gt0.tm_zone = gt->tm_zone;
>