Source: oath-toolkit
Version: 2.6.11
Tags: ftbfs, patch
X-Debbugs-Cc: del...@debian.org
User: debian-...@lists.debian.org
Usertags: time-t

As can be seen here:
https://buildd.debian.org/status/fetch.php?pkg=oath-toolkit&arch=hppa&ver=2.6.11-2.1&stamp=1713624192&raw=0
oath-toolkit testsuite fails on hppa like this:

FAIL: oathtool --verbose --totp --now @0 00
expected:
Start time: 1970-01-01 00:00:00 UTC (0)
Current time: 1970-01-01 00:00:00 UTC (0)
got:
Start time: 1970-01-01 00:00:00 UTC (2130640639)
Current time: 1970-01-01 00:00:00 UTC (35)

The failure stems from the fact that hppa is a 32-bit big-endian platform,
and which is the reason as well, why it does not fail on 32-bit little endian 
platforms.
(Although this is not an issue on arm, I nevertheless added the usertag since 
this bug in timet related)

The C-code is similar to this:
printf ("Current time: %ld\n", tim);
where tim is of type "time_t".

time_t can be 32- or 64-bit, depending on compile flags.
On Debian we now did for 32-bit platforms the time64 transition, which
made that value become a 64-bit entity.
So, the "%ld" printf format which defines 32-bit values on hppa does not
fit to the 64-bit tim value stored on the stack. Additionally hppa has
alignment requirements for 64-bit values which are put on the stack, which
is why a wrong value is printed in the testcase.

Solution is either to apply the attached patch, or to make printf
use "%ld" for 32-bit time_t and "%lld" for 64-bit time_t, which needs
to be checked at compile-time.
--- oathtool/oathtool.c.org	2024-04-29 11:55:18.854982447 +0000
+++ oathtool/oathtool.c	2024-04-29 11:57:34.646507216 +0000
@@ -96,6 +96,7 @@
 {
   struct tm tmp;
   char outstr[200];
+  long long counter;
 
   printf ("TOTP mode: %s\n", flags == OATH_TOTP_HMAC_SHA256 ? "SHA256" :
 	  flags == OATH_TOTP_HMAC_SHA512 ? "SHA512" :
@@ -107,8 +108,8 @@
   if (strftime (outstr, sizeof (outstr), "%Y-%m-%d %H:%M:%S UTC", &tmp) == 0)
     error (EXIT_FAILURE, 0, "strftime");
 
-  printf ("Step size (seconds): %ld\n", time_step_size);
-  printf ("Start time: %s (%ld)\n", outstr, t0);
+  printf ("Step size (seconds): %lld\n", (long long)time_step_size);
+  printf ("Start time: %s (%lld)\n", outstr, (long long)t0);
 
   if (gmtime_r (&when, &tmp) == NULL)
     error (EXIT_FAILURE, 0, "gmtime_r");
@@ -116,9 +117,9 @@
   if (strftime (outstr, sizeof (outstr), "%Y-%m-%d %H:%M:%S UTC", &tmp) == 0)
     error (EXIT_FAILURE, 0, "strftime");
 
-  printf ("Current time: %s (%ld)\n", outstr, when);
-  printf ("Counter: 0x%lX (%ld)\n\n", (when - t0) / time_step_size,
-	  (when - t0) / time_step_size);
+  printf ("Current time: %s (%lld)\n", outstr, (long long)when);
+  counter = (when - t0) / time_step_size;
+  printf ("Counter: 0x%llX (%lld)\n\n", counter, counter);
 }
 
 #define generate_otp_p(n) ((n) == 1)
  • Bug#1070056: oath-toolki... Helge Deller via OATH Toolkit general discussions

Reply via email to