1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

agent: Use clock or clock_gettime for calibration.

* agent/protect.c (calibrate_get_time): Use clock or clock_gettime.

--

For calibration, clock(3) is better than times(3) among UNIXen.
Tested on NetBSD 7.1 and FreeBSD 11.1, using QEMU.

Thanks to Damien Goutte-Gattat for the information of use of
CLOCKS_PER_SEC;  The old code with times(3) is not 100% correct,
in terms of POSIX.  It should have used sysconf (_SC_CLK_TCK) instead
of CLOCKS_PER_SEC.  CLOCKS_PER_SEC is specifically for clock(3).

GnuPG-bug-id: 3056, 3276, 3472
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
(cherry picked from commit 380bce13d9)
This commit is contained in:
NIIBE Yutaka 2017-11-07 10:49:36 +09:00 committed by Werner Koch
parent 3ecd1a41be
commit 760aa8aada
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 10 additions and 6 deletions

View file

@ -322,9 +322,9 @@ test_agent_protect_shared_secret (void)
int
main (int argc, char **argv)
{
(void)argc;
(void)argv;
opt.verbose = argc - 1; /* We can do "./t-protect -v -v" */
gcry_control (GCRYCTL_DISABLE_SECMEM);
test_agent_protect ();