developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame^] | 1 | From: Felix Fietkau <nbd@nbd.name> |
| 2 | Date: Thu, 8 Jul 2021 16:33:03 +0200 |
| 3 | Subject: [PATCH] hostapd: fix use of uninitialized stack variables |
| 4 | |
| 5 | When a CSA is performed on an 80 MHz channel, hostapd_change_config_freq |
| 6 | unconditionally calls hostapd_set_oper_centr_freq_seg0/1_idx with seg0/1 |
| 7 | filled by ieee80211_freq_to_chan. |
| 8 | However, if ieee80211_freq_to_chan fails (because the freq is 0 or invalid), |
| 9 | seg0/1 remains uninitialized and filled with stack garbage, causing errors |
| 10 | such as "hostapd: 80 MHz: center segment 1 configured" |
| 11 | |
| 12 | Signed-off-by: Felix Fietkau <nbd@nbd.name> |
| 13 | --- |
| 14 | |
| 15 | --- a/src/ap/hostapd.c |
| 16 | +++ b/src/ap/hostapd.c |
| 17 | @@ -3453,7 +3453,7 @@ static int hostapd_change_config_freq(st |
| 18 | struct hostapd_freq_params *old_params) |
| 19 | { |
| 20 | int channel; |
| 21 | - u8 seg0, seg1; |
| 22 | + u8 seg0 = 0, seg1 = 0; |
| 23 | struct hostapd_hw_modes *mode; |
| 24 | |
| 25 | if (!params->channel) { |