Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Aaron Hopkins <go-sql-driver at die.net>
Arne Hormann <arnehormann at gmail.com>
Carlos Nieto <jose.carlos at menteslibres.net>
Chris Moos <chris at tech9computers.com>
Daniël van Eeden <daniel.van.eeden at myname.nl>
DisposaBoy <disposaboy at dby.me>
Frederick Mayle <frederickmayle at gmail.com>
Gustavo Kristic <gkristic at gmail.com>
Expand Down
17 changes: 17 additions & 0 deletions packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
clientLongPassword |
clientTransactions |
clientLocalFiles |
clientConnectAttrs |
mc.flags&clientLongFlag

if mc.cfg.clientFoundRows {
Expand All @@ -228,7 +229,12 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
// User Password
scrambleBuff := scramblePassword(cipher, []byte(mc.cfg.passwd))

attrname := []byte("_client_name")
attrvalue := []byte("Go MySQL Driver")
attrlen := len(attrname) + len(attrvalue) + 2

pktLen := 4 + 4 + 1 + 23 + len(mc.cfg.user) + 1 + 1 + len(scrambleBuff)
pktLen += len(attrname) + len(attrvalue) + 3

// To specify a db name
if n := len(mc.cfg.dbname); n > 0 {
Expand Down Expand Up @@ -295,6 +301,17 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
pos += copy(data[pos:], mc.cfg.dbname)
data[pos] = 0x00
}
pos++

// Connection attributes
data[pos] = byte(attrlen)
pos++

data[pos] = byte(len(attrname))
pos += 1 + copy(data[pos+1:], attrname)

data[pos] = byte(len(attrvalue))
pos += 1 + copy(data[pos+1:], attrvalue)

// Send Auth packet
return mc.writePacket(data)
Expand Down