From: Alan T. DeKok Date: Fri, 14 Feb 2025 13:10:58 +0000 (-0500) Subject: fix ubsan warning about shifting signed numbers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d9ae2fc158a586e9690b4ed3fd527306e2f9216;p=thirdparty%2Ffreeradius-server.git fix ubsan warning about shifting signed numbers --- diff --git a/src/protocols/der/encode.c b/src/protocols/der/encode.c index 9107d47624d..6e394a3e018 100644 --- a/src/protocols/der/encode.c +++ b/src/protocols/der/encode.c @@ -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;