~emersion/soju

40a40566f4b5ae5a5117b09e03bbb8a512417207 — Simon Ser 10 months ago 2b2a2fd
msgstore/znclog: fix error message

err may be nil.

Fixes: 2b2a2fd4798d ("msgstore/znclog: fix panic on malformed input line")
1 files changed, 3 insertions(+), 1 deletions(-)

M msgstore/znclog/reader.go
M msgstore/znclog/reader.go => msgstore/znclog/reader.go +3 -1
@@ 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:]