Skip to content

wifi: connect() hands the port no unset buffer - #12049

Open
lynt-smitka wants to merge 1 commit into
adafruit:mainfrom
MakerClassCZ:fix-wifi-connect-buffers
Open

lynt-smitka wants to merge 1 commit into
adafruit:mainfrom
MakerClassCZ:fix-wifi-connect-buffers

Conversation

@lynt-smitka

Copy link
Copy Markdown

I found this while working on CP Desktop Lab, which is built with clang. Without a password or BSSID, connect() passed buffers with an unset buf pointer to the port. Clang treats that as undefined behavior and dropped the bssid is None check, so connect() without a BSSID raised TypeError. GCC builds work today, but a future GCC could do the same. This zero-initializes the three buffers, which also saves 40 bytes on the Pico W.

Without a password or a BSSID, their mp_buffer_info_t was left unset apart
from len and passed to common_hal_wifi_radio_connect() anyway. Clang treats
passing an undefined value as impossible and dropped the bssid None check,
so connect() without a bssid raised TypeError in a clang build.
Zero-initialize all three buffers.
@anecdata

anecdata commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Perhaps unrelated, but I just noticed that connect gives TypeError: unexpected keyword argument 'timeout' or TypeError: unexpected keyword argument 'channel', if it's an open network and password is empty or None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants