]> git.sur5r.net Git - openldap/commitdiff
ITS#8230 Don't skip tval on big-endian
authorHoward Chu <hyc@openldap.org>
Fri, 25 Sep 2015 17:52:24 +0000 (18:52 +0100)
committerHoward Chu <hyc@openldap.org>
Fri, 25 Sep 2015 17:52:24 +0000 (18:52 +0100)
contrib/slapd-modules/passwd/totp/slapd-totp.c

index 5596b3d7fa715509d25bfa7f4d9d014e98e98858..fe816c987a70df3ba5d7dff9696d927e8a1a961c 100644 (file)
 
 #include <portable.h>
 
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 #include <lber.h>
 #include <lber_pvt.h>
 #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;