Skip to contentSkip to conversation

network: add L_WARN for known network lookup failure

PATCH Applied James Prestwood 2 participants 2 messages Oct 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 network: add L_WARN for known network lookup failure

When updating the network ranking there was a potential out of bounds array access. The condition was if known_network_offset returned a negative value, indicating the known network was not found. Since network->info is only set for known networks this should not ever happen as network->info is checked prior.

Though this is likely impossible, knownnetworks is complex enough that its better to just be paranoid and put an L_WARN_ON to check the return.

---
 src/network.c | 2 ++
 1 file changed, 2 insertions(+)
src/network.c +2 -0
index 3270b57c..0f29022b 100644
@@ -1376,6 +1376,8 @@ void network_rank_update(struct network *network, bool connected)
 	if (network->info->connected_time != 0) {
 		int n = known_network_offset(network->info);
 
+		L_WARN_ON(n < 0);
+
 		if (n >= (int) L_ARRAY_SIZE(rankmod_table))
 			n = L_ARRAY_SIZE(rankmod_table) - 1;
 
Signature · 1 line
2.21.0
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

When updating the network ranking there was a potential out of bounds array access. The condition was if known_network_offset returned a negative value, indicating the known network was not found. Since network->info is only set for known networks this should not ever happen as network->info is checked prior.

Quoted 7 lines

Though this is likely impossible, knownnetworks is complex enough that its better to just be paranoid and put an L_WARN_ON to check the return.

---
  src/network.c | 2 ++
  1 file changed, 2 insertions(+)

Applied, thanks.

Regards,
-Denis