]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use correct data types, and check for overflow
authorAlan T. DeKok <aland@freeradius.org>
Sun, 19 Nov 2023 14:17:49 +0000 (09:17 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 19 Nov 2023 14:18:57 +0000 (09:18 -0500)
src/modules/rlm_unix/rlm_unix.c

index c1ca343ad8e162a78dabbe405ac120a1fb78e833..12a49cdbf6c6eaccaa8f1017d94b006735b7207d 100644 (file)
@@ -377,10 +377,9 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo
        fr_pair_t               *vp;
        FILE                    *fp;
        struct utmp             ut;
-       time_t                  t;
+       uint64_t                t;
        char                    buf[64];
        char const              *s = NULL;
-       int                     delay = 0;
        int                     status = -1;
        int                     nas_address = 0;
        int                     framed_address = 0;
@@ -459,9 +458,16 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo
                        port_seen = true;
 
                } else if (vp->da == attr_acct_delay_time) {
+                       uint32_t delay;
+
                        delay = vp->vp_uint32;
+
+                       if (t < delay) return RLM_MODULE_FAIL;
+
+                       t -= delay;
                }
        }
+       if (t > UINT32_MAX) return RLM_MODULE_FAIL;
 
        /*
         *      We don't store !root sessions, or sessions
@@ -505,9 +511,9 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo
        }
 #endif
 #ifdef USE_UTMPX
-       ut.ut_xtime = t - delay;
+       ut.ut_xtime = t;
 #else
-       ut.ut_time = t - delay;
+       ut.ut_time = t;
 #endif
 #ifdef USER_PROCESS
        /*