The Linux mcde_sys_wifi_join passes the network name to
"nmcli device wifi connect NAME ...". The name of an access point is what the
neighbour's device broadcasts. Measured with nmcli 1.56.1:
nmcli device wifi connect --ask password PW ifname IF
-> "Error: invalid extra argument 'PW'" -- the name was taken as the option
--ask (a name of -x, --help or - is taken as a name; no effect).
"--" in front is no remedy: nmcli takes the "--" for the name ("invalid extra
argument 'Home'" for a normal name). The password is safe: it is the argument
of the keyword "password" whatever it starts with.
So the Linux branch refuses a name that starts with "-" (mcde_sys_wifi_ssid_arg_ok
in net.c, with the old 1..32 byte rule); the NetBSD branch does not call nmcli.
A legitimate network called "-something" cannot be joined from System Settings
on Linux; the message is the old one ("The network name cannot be used").
test_netinput: 11 more checks; make check 6 of 6; with the dash rule removed the
test fails (checked with a mutant).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The checks that keep a typed network name and password out of
wpa_supplicant.conf and rc.conf (netbsd.c, mcde_sys_wifi_join) sat inline in
the NetBSD branch, behind geteuid() != 0: no test of the build could run them.
They are mcde_sys_wifi_config_ok in net.c now (one implementation for the file
that is built on every system), the NetBSD branch calls it, and the new
test_netinput.c runs 46 checks as an ordinary user: name 1..32 bytes (33
refused), passphrase none or 8..63 (7 and 64 refused), a quote, a backslash or
a newline in either (also a whole injected "network={" block), the interface
name (lower case and digits only), plus the two helpers net.c already had
without a test: mcde_sys_net_ifname_ok and mcde_sys_net_prefix (a
non-contiguous netmask, trailing text).
One behaviour change, found by writing the table: an EMPTY interface name
passed the inline check (strspn("") == strlen("")) and would have given
wpa_supplicant_flags="-B -s -i -D bsd ..."; it is refused now.
Measured: make check 6 of 6. Mutation check: with the SSID limit raised to 33,
with the empty-name guard removed, with the passphrase minimum 7, and with the
quote check left out of the passphrase, test_netinput fails (1, 1, 1 and 2
cases); the real code passes. netbsd.c and net.c compile for NetBSD
(x86_64--netbsd-gcc) without a diagnostic. Not run on NetBSD.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>