Skip to content

Commit a9a4bf4

Browse files
committed
fix panic when Xor handles different length of input
Signed-off-by: lance6716 <[email protected]>
1 parent 5dc9e7c commit a9a4bf4

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

mysql/mysql_gtid.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,6 @@ func (s IntervalSlice) Normalize() IntervalSlice {
111111
return n
112112
}
113113

114-
func min(a, b int64) int64 {
115-
if a < b {
116-
return a
117-
}
118-
return b
119-
}
120-
121-
func max(a, b int64) int64 {
122-
if a > b {
123-
return a
124-
}
125-
return b
126-
}
127-
128114
func (s *IntervalSlice) InsertInterval(interval Interval) {
129115
var (
130116
count int

mysql/util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ func CalcNativePassword(scramble, password []byte) []byte {
5656
return Xor(scrambleHash, stage1)
5757
}
5858

59-
// Xor hash1 modified in-place with XOR against hash2
59+
// Xor modifies hash1 in-place with XOR against hash2
6060
func Xor(hash1 []byte, hash2 []byte) []byte {
61-
for i := range hash1 {
61+
l := min(len(hash1), len(hash2))
62+
for i := range l {
6263
hash1[i] ^= hash2[i]
6364
}
6465
return hash1

0 commit comments

Comments
 (0)