From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: Marek Lindner <lindner_marek@yahoo.de>
Cc: b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org
Subject: Logic bug in B.A.T.M.A.N. advanced driver
Date: Sat, 29 Oct 2011 20:45:43 +0200 [thread overview]
Message-ID: <4EAC49D7.2060609@intra2net.com> (raw)
Hi Marek,
Consider this code from "net/batman-adv/bitarray.c":
int bit_get_packet(void *priv, unsigned long *seq_bits,
int32_t seq_num_diff, int set_mark)
{
...
if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE)
|| (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
bat_dbg(DBG_BATMAN, bat_priv,
"We missed a lot of packets (%i) !\n",
seq_num_diff - 1);
bit_reset_window(seq_bits);
if (set_mark)
bit_mark(seq_bits, 0);
return 1;
}
-----------------------------------
The defines from "main.h":
#define TQ_LOCAL_WINDOW_SIZE 64
#define EXPECTED_SEQNO_RANGE 65536
So that if() statement will translate to:
-----------------------------------
if ((seq_num_diff >= 64)
|| (seq_num_diff < 65536)) {
-----------------------------------
and this will always evaluate to true.
Detected by "cppcheck":
"[net/batman-adv/bitarray.c:157]: (warning) Mutual exclusion over ||
always evaluates to true. Did you intend to use && instead?"
Cheers,
Thomas
next reply other threads:[~2011-10-29 18:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-29 18:45 Thomas Jarosch [this message]
[not found] ` <4EAC49D7.2060609-XXsH3GEs1jrby3iVrkZq2A@public.gmane.org>
2011-10-30 15:22 ` [PATCH] batman-adv: Fix range check for expected packets Simon Wunderlich
[not found] ` <1319988163-3249-1-git-send-email-siwu-MaAgPAbsBIVS8oHt8HbXEIQuADTiUCJX@public.gmane.org>
2011-10-30 20:58 ` Marek Lindner
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=4EAC49D7.2060609@intra2net.com \
--to=thomas.jarosch@intra2net.com \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=lindner_marek@yahoo.de \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).