commit 0d7fbfe523b6fd1d9477b1c73e4c1571e7dd2f65
parent cf6499387f52ccf5ebc86a3025be9a0343a0930f
Author: James Prestwood <prestwoj@gmail.com>
Date: Fri, 25 Oct 2019 12:53:21 -0400
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.
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/network.c b/src/network.c
@@ -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;