Skip to content

Commit 4140bdf

Browse files
committed
Apply a fix for CVE-2026-45255 from FreeBSD
1 parent bf6ea19 commit 4140bdf

2 files changed

Lines changed: 49 additions & 25 deletions

File tree

usr.sbin/bsdconfig/share/media/wlan.subr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ f_dialog_scan_wireless()
780780
# f_dialog_wireless_edit $ssid
781781
#
782782
# Display a menu to allow the user to either create a new entry for the
783-
# wpa_supplicants.conf(5) file, or to edit values for an existing entry.
783+
# wpa_supplicant.conf(5) file, or to edit values for an existing entry.
784784
#
785785
# If more than one wireless network is found to match $ssid, a sub-menu is
786786
# presented, allowing the user to select the desired network.
@@ -813,6 +813,7 @@ f_dialog_wireless_edit()
813813
[ $nmatches -le ${#DIALOG_MENU_TAGS} ] || break
814814
f_substr -v tag "$DIALOG_MENU_TAGS" $nmatches 1
815815

816+
f_shell_escape "$wssid" wssid
816817
f_wireless_describe WIRELESS_$n help
817818
menu_list1="$menu_list1
818819
'$tag $wssid' '$wbssid' '$help'
@@ -913,7 +914,7 @@ f_dialog_wireless_edit()
913914
#
914915
# XXXDT Unfinished
915916
# This is where we display a menu that edits the entry
916-
# And then we modify the wpa_supplicants.conf(5) config file
917+
# And then we modify the wpa_supplicant.conf(5) config file
917918
# XXXDT Unfinished
918919
#
919920

@@ -1076,6 +1077,7 @@ f_menu_wireless_configs()
10761077
while [ $n -lt $nunique ]; do
10771078
n=$(( $n + 1 ))
10781079
menuitem_$n get ssid ssid
1080+
f_shell_escape "$ssid" ssid
10791081

10801082
menuitem_$n get nconfigs nconfigs
10811083
desc="$nconfigs $msg_configured_lc"
@@ -1184,6 +1186,7 @@ f_menu_wpa_scan_results()
11841186
while [ $n -lt $nunique ]; do
11851187
n=$(( $n + 1 ))
11861188
menuitem_$n get ssid ssid
1189+
f_shell_escape "$ssid" ssid
11871190

11881191
desc=
11891192
if [ "$DIALOG_MENU_WLAN_SHOW_ALL" ]; then
@@ -1207,7 +1210,7 @@ f_menu_wpa_scan_results()
12071210

12081211
# f_dialog_menu_wireless_edit
12091212
#
1210-
# Display a list of wireless networks configured in wpa_supplicants.conf(5) and
1213+
# Display a list of wireless networks configured in wpa_supplicant.conf(5) and
12111214
# (if wpa_supplicant(8) is running) also displays scan results for unconfigured
12121215
# wireless networks.
12131216
#
@@ -1246,7 +1249,7 @@ f_dialog_menu_wireless_edit()
12461249
fi
12471250
if [ "$do_parse" -a "$DIALOG_MENU_WLAN_SHOW_CONFIGURED" ]
12481251
then
1249-
f_dprintf "$funcname: Parsing wpa_supplicants.conf(5)"
1252+
f_dprintf "$funcname: Parsing wpa_supplicant.conf(5)"
12501253
f_wpa_supplicant_parse "$conf_file" \
12511254
WIRELESS_ NWIRELESS_CONFIGS
12521255
f_dprintf "%s: Parsed %i wireless configurations" \
@@ -1261,7 +1264,7 @@ f_dialog_menu_wireless_edit()
12611264

12621265
#
12631266
# Add both items scanned from the airwaves and networks
1264-
# parsed from wpa_supplicants.conf(5). Latter items are
1267+
# parsed from wpa_supplicant.conf(5). Latter items are
12651268
# marked, sorted, and added to top of list above the
12661269
# former (which are unmarked and sorted separately).
12671270
#

usr.sbin/bsdinstall/scripts/wlanconfig

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ country_set()
5555
"$WLAN_IFACE" "$ifconfig_args"
5656
error_str="${error_str#ifconfig: }"
5757
# Restart wpa_supplicant(8) (should not fail).
58-
[ "$iface_up" ] && f_eval_catch -d wlanconfig wpa_supplicant \
58+
[ "$iface_up" ] && ifconfig "$WLAN_IFACE" up && \
59+
f_eval_catch -d wlanconfig wpa_supplicant \
5960
'wpa_supplicant -B -i "%s" -c "%s/wpa_supplicant.conf"' \
6061
"$WLAN_IFACE" "$BSDINSTALL_TMPETC"
6162
if [ "$error_str" ]; then
@@ -91,7 +92,7 @@ dialog_country_select()
9192
sub(/.*domains:/, ""), /[^[:alnum:][[:space:]]/ {
9293
n = split($0, domains)
9394
for (i = 1; i <= n; i++)
94-
printf "'\''%s'\'' '\'\''", domains[i]
95+
printf "'\''%s'\'' '\'\''\n", domains[i]
9596
}
9697
' | sort )
9798
countries=$( echo "$input" | awk '
@@ -146,6 +147,34 @@ dialog_country_select()
146147
country_set "$regdomain" "$country"
147148
}
148149

150+
dialog_network_select()
151+
{
152+
local ssid flags height width rows prompt
153+
154+
# Avoid using eval on untrusted data.
155+
set --
156+
while IFS=$'\t' read -r ssid flags; do
157+
[ -n "$ssid" ] || continue
158+
set -- "$@" "$ssid" "$flags"
159+
done <<EOF
160+
$NETWORKS
161+
EOF
162+
163+
f_dialog_title "Network Selection"
164+
prompt="Select a wireless network to connect to."
165+
f_dialog_menu_size height width rows \
166+
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt" "" "$@"
167+
$DIALOG \
168+
--title "$DIALOG_TITLE" \
169+
--backtitle "$DIALOG_BACKTITLE" \
170+
--extra-button \
171+
--extra-label "Rescan" \
172+
--menu "$prompt" \
173+
$height $width $rows \
174+
"$@" \
175+
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
176+
}
177+
149178
############################################################ MAIN
150179

151180
: > "$BSDINSTALL_TMPETC/wpa_supplicant.conf"
@@ -199,36 +228,28 @@ fi
199228

200229
while :; do
201230
SCANSSID=0
231+
# While wpa_supplicant may IFF_UP the interface, we do not want to rely
232+
# in this. In case the script is run manually (outside the installer,
233+
# e.g., for testing) wpa_supplicant may be running and the wlanN
234+
# interface may be down (especially if dialog_country_select is not
235+
# run successfully either) and scanning will not work.
236+
f_eval_catch -d wlanconfig ifconfig "ifconfig $WLAN_IFACE up"
202237
f_eval_catch -d wlanconfig wpa_cli "wpa_cli scan"
203238
f_dialog_title "Scanning"
204239
f_dialog_pause "Waiting 5 seconds to scan for wireless networks..." 5 ||
205240
exit 1
206241

207242
f_eval_catch -dk SCAN_RESULTS wlanconfig wpa_cli "wpa_cli scan_results"
208243
NETWORKS=$( echo "$SCAN_RESULTS" | awk -F '\t' '
209-
/..:..:..:..:..:../ && $5 { printf "\"%s\"\t\"%s\"\n", $5, $4 }
244+
/..:..:..:..:..:../ && $5 { print $5 "\t" $4 }
210245
' | sort | uniq )
211246

212247
if [ ! "$NETWORKS" ]; then
213248
f_dialog_title "$msg_error"
214249
f_yesno "No wireless networks were found. Rescan?" && continue
215-
exit 1
250+
else
251+
NETWORK=$( dialog_network_select )
216252
fi
217-
218-
f_dialog_title "Network Selection"
219-
prompt="Select a wireless network to connect to."
220-
f_dialog_menu_size height width rows "$DIALOG_TITLE" \
221-
"$DIALOG_BACKTITLE" "$prompt" "" $menu_list
222-
NETWORK=$( eval $DIALOG \
223-
--title \"\$DIALOG_TITLE\" \
224-
--backtitle \"\$DIALOG_BACKTITLE\" \
225-
--extra-button \
226-
--extra-label \"Rescan\" \
227-
--menu \"\$prompt\" \
228-
$height $width $rows \
229-
$NETWORKS \
230-
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
231-
)
232253
retval=$?
233254
f_dialog_data_sanitize NETWORK
234255
case $retval in
@@ -264,7 +285,7 @@ while :; do
264285
done
265286

266287
[ "$ENCRYPTION" ] || ENCRYPTION=$( echo "$NETWORKS" |
267-
awk -F '\t' "/^\"$NETWORK\"\t/ { print \$2 }" )
288+
awk -F '\t' "/^$NETWORK\t/ { print \$2 }" )
268289

269290
if echo "$ENCRYPTION" | grep -q PSK; then
270291
PASS=$( $DIALOG \

0 commit comments

Comments
 (0)