From: Alan T. DeKok Date: Tue, 14 Sep 2021 15:49:23 +0000 (-0400) Subject: handle negative numbers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f39aa31e0adfa1e28edfb9e2e0fba24e0ec86adf;p=thirdparty%2Ffreeradius-server.git handle negative numbers --- diff --git a/src/lib/util/dbuff.h b/src/lib/util/dbuff.h index 336b5b2d6be..d0fc622e9db 100644 --- a/src/lib/util/dbuff.h +++ b/src/lib/util/dbuff.h @@ -1789,14 +1789,19 @@ static inline ssize_t _fr_dbuff_out_uint64v(uint64_t *num, uint8_t **pos_p, fr_d static inline ssize_t _fr_dbuff_out_int64v(int64_t *num, uint8_t **pos_p, fr_dbuff_t *dbuff, size_t length) { ssize_t slen; + bool negative; fr_assert(length > 0 && length <= sizeof(uint64_t)); + negative = *fr_dbuff_current(dbuff) & 0x80; + *num = 0; slen = _fr_dbuff_out_memcpy(((uint8_t *) num) + (8 - length), pos_p, dbuff, length); if (slen <= 0) return slen; *num = fr_net_to_int64((uint8_t const *)num); + if (negative) *num = -*num; + return length; }