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 clarify if check
@ 2014-09-17  7:01 Antonio Quartulli
  2014-09-20 16:17 ` Antonio Quartulli
  0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2014-09-17  7:01 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

Due to a typ0 in an if-condition used in the gateway-client
code it is possible to run in a NULL pointer dereference.

At the same type the same if-condition is not clear.

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>
---
 gateway_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gateway_client.c b/gateway_client.c
index bcc3e0c..5f09536 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 || (gw_node->bandwidth_down == 0))
 		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 clarify if check
  2014-09-17  7:01 [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and clarify if check Antonio Quartulli
@ 2014-09-20 16:17 ` Antonio Quartulli
  0 siblings, 0 replies; 2+ messages in thread
From: Antonio Quartulli @ 2014-09-20 16:17 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

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

Hi all,

On 17/09/14 09:01, Antonio Quartulli wrote:
>  	gw_node = batadv_gw_node_get(bat_priv, orig_dst_node);
> -	if (!gw_node->bandwidth_down == 0)
> +	if (!gw_node || (gw_node->bandwidth_down == 0))

This is not the right way to fix this condition. A new patch is coming.

Cheers,

-- 
Antonio Quartulli


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2014-09-20 16:17 UTC | newest]

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

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