]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: Fix timestamp output on 32-bit architectures
authorToke Høiland-Jørgensen <toke@toke.dk>
Thu, 18 Mar 2021 22:46:55 +0000 (23:46 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Mar 2021 12:33:32 +0000 (13:33 +0100)
On 32-bit architectures, time_t is 32-bit which causes overflows in the
arithmetic involving tv_sec, leading to invalid output. Fix this by
explicitly adding ULL suffixes to the constants used in those calculations.

Fixes: 3708f614dfdd ("iw: Print current time in station info dump")
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20210318224655.143489-1-toke@toke.dk
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
station.c

index bddea51815eef7267567b1371a6729c49a881c65..002cf13526cce9bb741f182b5ee6196239b06190 100644 (file)
--- a/station.c
+++ b/station.c
@@ -337,7 +337,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
        unsigned long long now_ms;
 
        gettimeofday(&now, NULL);
-       now_ms = now.tv_sec * 1000;
+       now_ms = now.tv_sec * 1000ULL;
        now_ms += (now.tv_usec / 1000);
 
        nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -601,7 +601,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
                unsigned long long assoc_at_ms;
 
                clock_gettime(CLOCK_BOOTTIME, &now_ts);
-               boot_ns = now_ts.tv_sec * 1000000000;
+               boot_ns = now_ts.tv_sec * 1000000000ULL;
                boot_ns += now_ts.tv_nsec;
 
                bt = (unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_ASSOC_AT_BOOTTIME]);