b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and fix if check
@ 2014-09-20 16:22 Antonio Quartulli
  2014-11-17 11:07 ` Marek Lindner
  0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2014-09-20 16:22 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

Gateway having bandwidth_down equal to zero are not accepted
at all and so never added to the Gateway list.
For this reason checking the bandwidth_down member in
batadv_gw_out_of_range() is useless.

This is probably a copy/paste error and this check was supposed
to be "!gw_node" only. Moreover, the way the check is written
now may also lead to a NULL dereference.

Fix this by rewriting the if-condition properly.

Introduced by 0853ec7fafe0a195754454832993c6b35e22b842
("batman-adv: tvlv - gateway download/upload bandwidth container")

Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Reported-by: David Binderman <dcb314@hotmail.com>
---

This patch makes "batman-adv: avoid NULL dereferences and clarify if check"
obsolete.


 gateway_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gateway_client.c b/gateway_client.c
index bcc3e0c..27649e8 100644
--- a/gateway_client.c
+++ b/gateway_client.c
@@ -811,7 +811,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
 		goto out;
 
 	gw_node = batadv_gw_node_get(bat_priv, orig_dst_node);
-	if (!gw_node->bandwidth_down == 0)
+	if (!gw_node)
 		goto out;
 
 	switch (atomic_read(&bat_priv->gw_mode)) {
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and fix if check
  2014-09-20 16:22 [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and fix if check Antonio Quartulli
@ 2014-11-17 11:07 ` Marek Lindner
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2014-11-17 11:07 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

On Saturday 20 September 2014 18:22:05 Antonio Quartulli wrote:
> Gateway having bandwidth_down equal to zero are not accepted
> at all and so never added to the Gateway list.
> For this reason checking the bandwidth_down member in
> batadv_gw_out_of_range() is useless.
> 
> This is probably a copy/paste error and this check was supposed
> to be "!gw_node" only. Moreover, the way the check is written
> now may also lead to a NULL dereference.
> 
> Fix this by rewriting the if-condition properly.
> 
> Introduced by 0853ec7fafe0a195754454832993c6b35e22b842
> ("batman-adv: tvlv - gateway download/upload bandwidth container")
> 
> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
> Reported-by: David Binderman <dcb314@hotmail.com>
> ---
> 
> This patch makes "batman-adv: avoid NULL dereferences and clarify if check"
> obsolete.
> 
> 
>  gateway_client.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied in revision cb2b79e.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-17 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-20 16:22 [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and fix if check Antonio Quartulli
2014-11-17 11:07 ` Marek Lindner

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).