]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_pknock: repair do_div invocation
authorJan Engelhardt <jengelh@inai.de>
Sat, 30 Dec 2023 17:06:25 +0000 (18:06 +0100)
committerJan Engelhardt <jengelh@inai.de>
Sat, 30 Dec 2023 17:28:00 +0000 (18:28 +0100)
do_div modifies its argument in-place. Account for that behavior.

Fixes: v3.15-1-g3aa4ca3
extensions/pknock/xt_pknock.c

index 1606eabce9e86ddfa5bddf900f2a2c7865a91744..9388c49d509fda02b652c81dc214900fab6f5e1d 100644 (file)
@@ -343,7 +343,9 @@ has_logged_during_this_minute(const struct peer *peer)
                return 0;
        x = ktime_get_seconds();
        y = peer->login_sec;
-       return do_div(y, 60) == do_div(x, 60);
+       do_div(x, 60);
+       do_div(y, 60);
+       return x == y;
 }
 
 /**
@@ -731,7 +733,8 @@ has_secret(const unsigned char *secret, unsigned int secret_len, uint32_t ipsrc,
        if (hexresult == NULL)
                return false;
        x = ktime_get_seconds();
-       epoch_min = do_div(x, 60);
+       do_div(x, 60);
+       epoch_min = x;
 
        ret = crypto_shash_setkey(crypto.tfm, secret, secret_len);
        if (ret != 0) {