Skip to content

Commit

Permalink
Fix ipmi panic (influxdata#9035)
Browse files Browse the repository at this point in the history
  • Loading branch information
helenosheaa authored Mar 23, 2021
1 parent dc8e4ef commit f4a51a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/inputs/ipmi_sensor/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ func NewConnection(server, privilege, hexKey string) *Connection {
security := server[0:inx1]
connstr = server[inx1+1:]
up := strings.SplitN(security, ":", 2)
conn.Username = up[0]
conn.Password = up[1]
if len(up) == 2 {
conn.Username = up[0]
conn.Password = up[1]
}
}

if inx2 > 0 {
Expand Down
12 changes: 12 additions & 0 deletions plugins/inputs/ipmi_sensor/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ func TestNewConnection(t *testing.T) {
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 {
Expand Down

0 comments on commit f4a51a4

Please sign in to comment.