From 6e4c747d5dced4df6ee7b5fd1450628d0bb5b56f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 25 Sep 2015 18:52:24 +0100 Subject: [PATCH] ITS#8230 Don't skip tval on big-endian --- contrib/slapd-modules/passwd/totp/slapd-totp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contrib/slapd-modules/passwd/totp/slapd-totp.c b/contrib/slapd-modules/passwd/totp/slapd-totp.c index 5596b3d7fa..fe816c987a 100644 --- a/contrib/slapd-modules/passwd/totp/slapd-totp.c +++ b/contrib/slapd-modules/passwd/totp/slapd-totp.c @@ -20,6 +20,10 @@ #include +#if HAVE_STDINT_H +#include +#endif + #include #include #include "lutil.h" @@ -314,7 +318,7 @@ static const int DIGITS_POWER[] = { static void generate( myval *key, - unsigned long tval, + uint64_t long tval, int digits, myval *out, const void *mech) @@ -325,8 +329,9 @@ static void generate( unsigned char msg[8]; int i, offset, res, otp; -#if !WORDS_BIGENDIAN - /* only needed on little-endian, can just use tval directly on big-endian */ +#if WORDS_BIGENDIAN + *(uint64_t *)msg = tval; +#else for (i=7; i>=0; i--) { msg[i] = tval & 0xff; tval >>= 8; -- 2.39.5