]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix ubsan warning about shifting signed numbers
authorAlan T. DeKok <aland@freeradius.org>
Fri, 14 Feb 2025 13:10:58 +0000 (08:10 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 14 Feb 2025 13:10:58 +0000 (08:10 -0500)
src/protocols/der/encode.c

index 9107d47624d847001aa6f0ecf55a482f89286c05..6e394a3e018e373af082b6b8eed2ffcb7df4607b 100644 (file)
@@ -161,7 +161,7 @@ static ssize_t fr_der_encode_integer(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, UN
 {
        fr_dbuff_t       our_dbuff = FR_DBUFF(dbuff);
        fr_pair_t const *vp;
-       int64_t          value;
+       uint64_t         value;
        uint8_t          first_octet = 0;
        size_t           i, len;
 
@@ -183,7 +183,13 @@ static ssize_t fr_der_encode_integer(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, UN
         *            second octet, followed by bits 8 to 1 of each octet in turn up to and including the last octet of
         *            the contents octets.
         */
-       value = vp->vp_int64;
+
+       /*
+        *      Yes, the type is FR_TYPE_INT64.  But we encode the
+        *      data as-is, without caring about things like signed
+        *      math.
+        */
+       value = vp->vp_uint64;
 
        for (i = 0, len = 0; i < sizeof(value); i++) {
                uint8_t byte = (value >> 56) & 0xff;