[android] reject an out-of-range SSH port

The port arrives as an int because gomobile cannot carry uint16 across the
Java boundary, so nothing rejected a value outside the valid range. It
reached strconv.Itoa and only surfaced as a dial failure, after the server
detection had already spent its timeout.
This commit is contained in:
Zoltán Papp
2026-08-11 15:05:58 +02:00
parent c1c8ee832e
commit a33e981c26

View File

@@ -115,6 +115,10 @@ func (s *SSHClient) SetURLOpener(opener URLOpener) {
//
// The password parameter is only consulted for regular SSH servers.
func (s *SSHClient) Connect(host string, port int, user, password string) error {
if port < 1 || port > 65535 {
return fmt.Errorf("invalid port: %d", port)
}
cfg, _, cc := s.nb.stateSnapshot()
if cc == nil {
return errors.New("netbird client not running")