]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Make IN_RANGE_INTEGER_*() nontrivial iff it can actually fail (CID #1445201)
authorJames Jones <jejones3141@gmail.com>
Wed, 8 Nov 2023 22:29:49 +0000 (16:29 -0600)
committerAlan DeKok <aland@freeradius.org>
Thu, 18 Jan 2024 14:36:11 +0000 (09:36 -0500)
The range check can only fail if PTRDIFF_MAX < INT64_MAX. Since
that's not the case for the Coverity run, you get a defect of the
result_independent_of_operands flavor, just like the range checks
for fr_sbuff_out_[u]int64() used to.

The floating point version, I believe, will notice +/-infinity
and denormalized numbers, so Coverity wouldn't complain about it.

src/modules/rlm_lua/lua.c

index ebbb58bc0fba11af3cf736a3e290d199e792eddf..3a15db339867f2107a0dd7f63fd65627a8dbe743 100644 (file)
@@ -56,6 +56,7 @@ static int fr_lua_marshall(request_t *request, lua_State *L, fr_pair_t const *vp
 {
        if (!vp) return -1;
 
+#if PTRDIFF_MAX < INT64_MAX
 #define IN_RANGE_INTEGER_SIGNED(_x) \
        do { \
                if ((((int64_t)(_x)) < PTRDIFF_MIN) || (((int64_t)(_x)) > PTRDIFF_MAX)) { \
@@ -73,6 +74,15 @@ static int fr_lua_marshall(request_t *request, lua_State *L, fr_pair_t const *vp
                        return -1; \
                } \
        } while (0)
+#else
+#define IN_RANGE_INTEGER_SIGNED(_x) \
+        do { \
+        } while (0)
+
+#define IN_RANGE_INTEGER_UNSIGNED(_x) \
+        do { \
+        } while (0)
+#endif
 
 #define IN_RANGE_FLOAT_SIGNED(_x) \
        do { \