Skip to content

Commit 9bd5965

Browse files
authored
Merge pull request #10 from RiveryIO/feature/eitam/limit_max_host_name
Add limit to max host name length
2 parents 98108dd + 411b75d commit 9bd5965

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

replication/binlogsyncer.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import (
1919
)
2020

2121
var (
22-
errSyncRunning = errors.New("Sync is running, must Close first")
22+
errSyncRunning = errors.New("Sync is running, must Close first")
23+
maxHostNameLength = 60
2324
)
2425

2526
// BinlogSyncerConfig is the configuration for BinlogSyncer.
@@ -524,7 +525,10 @@ func (b *BinlogSyncer) writeRegisterSlaveCommand() error {
524525
b.c.ResetSequence()
525526

526527
hostname := b.localHostname()
527-
528+
if len(hostname) > maxHostNameLength {
529+
runes := []rune(hostname)
530+
hostname = string(runes[0:maxHostNameLength])
531+
}
528532
// This should be the name of slave host not the host we are connecting to.
529533
data := make([]byte, 4+1+4+1+len(hostname)+1+len(b.cfg.User)+1+len(b.cfg.Password)+2+4+4)
530534
pos := 4

0 commit comments

Comments
 (0)