msgstore/znclog: fix error message
err may be nil.
Fixes: 2b2a2fd479
("msgstore/znclog: fix panic on malformed input line")
This commit is contained in:
parent
2b2a2fd479
commit
40a40566f4
@ -16,8 +16,10 @@ var timestampPrefixLen = len("[01:02:03] ")
|
||||
func UnmarshalLine(line string, user *database.User, network *database.Network, entity string, ref time.Time, events bool) (*irc.Message, time.Time, error) {
|
||||
var hour, minute, second int
|
||||
_, err := fmt.Sscanf(line, "[%02d:%02d:%02d] ", &hour, &minute, &second)
|
||||
if err != nil || len(line) < timestampPrefixLen {
|
||||
if err != nil {
|
||||
return nil, time.Time{}, fmt.Errorf("malformed timestamp prefix: %v", err)
|
||||
} else if len(line) < timestampPrefixLen {
|
||||
return nil, time.Time{}, fmt.Errorf("malformed timestamp prefix: too short")
|
||||
}
|
||||
line = line[timestampPrefixLen:]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user