All of lore.kernel.org
 help / color / mirror / Atom feed
From: <andy@asjohnson.com>
To: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Subject: RE: [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86
Date: Sun, 28 Feb 2021 07:54:56 -0700	[thread overview]
Message-ID: <20210228075456.fcdaf64278890662106b299d41e0899d.6d7dc7cab7.wbe@email05.godaddy.com> (raw)

The original patch for long division on x86 didn't take into account
the use of short circuit logic for checking if peer is NULL before
testing it. Here is a revised patch to v3.16:

--- xtables-addons-3.16-orig/extensions/pknock/xt_pknock.c
+++ xtables-addons-3.16-patched/extensions/pknock/xt_pknock.c
@@ -311,9 +311,13 @@
 static inline bool
 autoclose_time_passed(const struct peer *peer, unsigned int
autoclose_time)
 {
-	unsigned long x = ktime_get_seconds();
-	unsigned long y = peer->login_sec + autoclose_time * 60;
-	return peer != NULL && autoclose_time != 0 && time_after(x, y);
+	if (peer != NULL) {
+		unsigned long x = ktime_get_seconds();
+		unsigned long y = peer->login_sec + autoclose_time * 60;
+		return autoclose_time != 0 && time_after(x, y);
+	} else {
+		return 0;
+	}
 }
 
 /**
@@ -335,8 +339,12 @@
 static inline bool
 has_logged_during_this_minute(const struct peer *peer)
 {
-	unsigned long x = ktime_get_seconds(), y = peer->login_sec;
-	return peer != NULL && do_div(y, 60) == do_div(x, 60);
+	if (peer != NULL) {
+		unsigned long x = ktime_get_seconds(), y = peer->login_sec;
+		return do_div(y, 60) == do_div(x, 60);
+	} else {
+		return 0;
+	}
 }
 
 /**


             reply	other threads:[~2021-02-28 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-28 14:54 andy [this message]
2021-02-28 16:57 ` [PATCH] xtables-addons 3.15 doesn't compile on 32-bit x86 Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2021-02-21 14:50 andy
2021-02-24  0:19 ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210228075456.fcdaf64278890662106b299d41e0899d.6d7dc7cab7.wbe@email05.godaddy.com \
    --to=andy@asjohnson.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.