Skip to content

Commit

Permalink
wioterminal: fix check for bad Wifi connect
Browse files Browse the repository at this point in the history
rpc_wifi_connect() will return 0 on successful connection, so check for
that.  Also, check that if passphrase is given, that it's the minimum 8
chars per WPA Wifi.
  • Loading branch information
scottfeldman authored and deadprogram committed Jan 11, 2024
1 parent 5c0f048 commit 7d24c3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions netlink/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
ErrConnectFailed = errors.New("Connect failed")
ErrConnectTimeout = errors.New("Connect timed out")
ErrMissingSSID = errors.New("Missing WiFi SSID")
ErrShortPassphrase = errors.New("Invalid Wifi Passphrase < 8 chars")
ErrAuthFailure = errors.New("Wifi authentication failure")
ErrAuthTypeNoGood = errors.New("Wifi authorization type not supported")
ErrConnectModeNoGood = errors.New("Connect mode not supported")
Expand Down
6 changes: 5 additions & 1 deletion rtl8720dn/rtl8720dn.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ func (r *rtl8720dn) connectToAP() error {
return netlink.ErrMissingSSID
}

if len(r.params.Passphrase) != 0 && len(r.params.Passphrase) < 8 {
return netlink.ErrShortPassphrase
}

if debugging(debugBasic) {
fmt.Printf("Connecting to Wifi SSID '%s'...", r.params.Ssid)
}

// Start the connection process
securityType := uint32(0x00400004)
result := r.rpc_wifi_connect(r.params.Ssid, r.params.Passphrase, securityType, -1, 0)
if result == -1 {
if result != 0 {
if debugging(debugBasic) {
fmt.Printf("FAILED\r\n")
}
Expand Down

0 comments on commit 7d24c3c

Please sign in to comment.