Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 341a5a5

Browse files
Fix auth_switch_request packet handling
auth_data contains last NUL. Fix #1666 Signed-off-by: Bes Dollma (bdollma) <bdollma@cisco.com>
1 parent 85c6311 commit 341a5a5

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

‎AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Ariel Mashraki <ariel at mashraki.co.il>
2323
Artur Melanchyk <artur.melanchyk@gmail.com>
2424
Asta Xie <xiemengjun at gmail.com>
2525
B Lamarche <blam413 at gmail.com>
26+
Bes Dollma <bdollma@thousandeyes.com>
2627
Brian Hendriks <brian at dolthub.com>
2728
Bulat Gaifullin <gaifullinbf at gmail.com>
2829
Caine Jette <jette at alum.mit.edu>
@@ -146,4 +147,5 @@ PingCAP Inc.
146147
Pivotal Inc.
147148
Shattered Silicon Ltd.
148149
Stripe Inc.
150+
ThousandEyes
149151
Zendesk Inc.

‎auth_test.go‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ func TestAuthSwitchCachingSHA256PasswordCached(t *testing.T) {
734734

735735
expectedReply := []byte{
736736
// 1. Packet: Hash
737-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
738-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
739-
153, 9, 130,
737+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
738+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
739+
118, 211, 69,
740740
}
741741
if !bytes.Equal(conn.written, expectedReply) {
742742
t.Errorf("got unexpected data: %v", conn.written)
@@ -803,9 +803,9 @@ func TestAuthSwitchCachingSHA256PasswordFullRSA(t *testing.T) {
803803

804804
expectedReplyPrefix := []byte{
805805
// 1. Packet: Hash
806-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
807-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
808-
153, 9, 130,
806+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
807+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
808+
118, 211, 69,
809809

810810
// 2. Packet: Pub Key Request
811811
1, 0, 0, 5, 2,
@@ -848,9 +848,9 @@ func TestAuthSwitchCachingSHA256PasswordFullRSAWithKey(t *testing.T) {
848848

849849
expectedReplyPrefix := []byte{
850850
// 1. Packet: Hash
851-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
852-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
853-
153, 9, 130,
851+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
852+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
853+
118, 211, 69,
854854

855855
// 2. Packet: Encrypted Password
856856
0, 1, 0, 5, // [changing bytes]
@@ -891,9 +891,9 @@ func TestAuthSwitchCachingSHA256PasswordFullSecure(t *testing.T) {
891891

892892
expectedReply := []byte{
893893
// 1. Packet: Hash
894-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
895-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
896-
153, 9, 130,
894+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
895+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
896+
118, 211, 69,
897897

898898
// 2. Packet: Cleartext password
899899
7, 0, 0, 5, 115, 101, 99, 114, 101, 116, 0,

‎packets.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ func (mc *mysqlConn) readAuthResult() ([]byte, string, error) {
510510
}
511511
plugin := string(data[1:pluginEndIndex])
512512
authData := data[pluginEndIndex+1:]
513+
if len(authData) > 0 && authData[len(authData)-1] == 0 {
514+
authData = authData[:len(authData)-1]
515+
}
513516
return authData, plugin, nil
514517

515518
default: // Error otherwise

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /