Fix ipmi panic (#9035)
This commit is contained in:
parent
dc8e4ef62e
commit
f4a51a4c33
|
|
@ -32,8 +32,10 @@ func NewConnection(server, privilege, hexKey string) *Connection {
|
||||||
security := server[0:inx1]
|
security := server[0:inx1]
|
||||||
connstr = server[inx1+1:]
|
connstr = server[inx1+1:]
|
||||||
up := strings.SplitN(security, ":", 2)
|
up := strings.SplitN(security, ":", 2)
|
||||||
conn.Username = up[0]
|
if len(up) == 2 {
|
||||||
conn.Password = up[1]
|
conn.Username = up[0]
|
||||||
|
conn.Password = up[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if inx2 > 0 {
|
if inx2 > 0 {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,18 @@ func TestNewConnection(t *testing.T) {
|
||||||
HexKey: "0001",
|
HexKey: "0001",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// test connection doesn't panic if incorrect symbol used
|
||||||
|
{
|
||||||
|
"USERID@PASSW0RD@lan(192.168.1.1)",
|
||||||
|
&Connection{
|
||||||
|
Hostname: "192.168.1.1",
|
||||||
|
Username: "",
|
||||||
|
Password: "",
|
||||||
|
Interface: "lan",
|
||||||
|
Privilege: "USER",
|
||||||
|
HexKey: "0001",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range testData {
|
for _, v := range testData {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue