]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Verify center frequency seg0/seg1 mapping result before use
authorJouni Malinen <j@w1.fi>
Sun, 14 Jan 2024 18:21:26 +0000 (20:21 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 14 Jan 2024 19:14:42 +0000 (21:14 +0200)
Handle the center frequency to channel mapping more cleanly by skipping
the cases where the center frequencies are not set and verifying that
the mapping succeeds when they are set.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/hostapd.c

index d6e3e4ede0eb291a9b33709600948f7671d6e0fa..c2cb8afdaf356b09e6d204f3949659fa27714ad2 100644 (file)
@@ -3907,10 +3907,14 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
        conf->ieee80211n = params->ht_enabled;
        conf->ieee80211ac = params->vht_enabled;
        conf->secondary_channel = params->sec_channel_offset;
-       ieee80211_freq_to_chan(params->center_freq1,
-                              &seg0);
-       ieee80211_freq_to_chan(params->center_freq2,
-                              &seg1);
+       if (params->center_freq1 &&
+           ieee80211_freq_to_chan(params->center_freq1, &seg0) ==
+           NUM_HOSTAPD_MODES)
+               return -1;
+       if (params->center_freq2 &&
+           ieee80211_freq_to_chan(params->center_freq2,
+                                  &seg1) == NUM_HOSTAPD_MODES)
+               return -1;
        hostapd_set_oper_centr_freq_seg0_idx(conf, seg0);
        hostapd_set_oper_centr_freq_seg1_idx(conf, seg1);