internal/socks: permit authenticating with an empty password

The behavior is accepted widely, and I found no reason to deny it.

Fixes golang/go#57285

Change-Id: I39b07295cc89481ea0d6b70b71f2aa57f1a01407
GitHub-Last-Rev: b00ecb1d7a
GitHub-Pull-Request: golang/net#157
Reviewed-on: https://go-review.googlesource.com/c/net/+/457355
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
iseki 2022-12-14 05:37:03 +00:00 коммит произвёл Gopher Robot
Родитель 694cff8668
Коммит 3d5a8ee7d3
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -289,7 +289,7 @@ func (up *UsernamePassword) Authenticate(ctx context.Context, rw io.ReadWriter,
case AuthMethodNotRequired:
return nil
case AuthMethodUsernamePassword:
if len(up.Username) == 0 || len(up.Username) > 255 || len(up.Password) == 0 || len(up.Password) > 255 {
if len(up.Username) == 0 || len(up.Username) > 255 || len(up.Password) > 255 {
return errors.New("invalid username/password")
}
b := []byte{authUsernamePasswordVersion}