Skip to content

Commit 7d6c237

Browse files
committed
fixed slice bounds out of range panic in syslog handler
1 parent 8b9a858 commit 7d6c237

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

handlers/syslog/syslog.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
stdlog "log"
77
"os"
88
"strconv"
9+
"strings"
910

1011
syslog "github.com/RackSec/srslog"
1112

@@ -349,7 +350,9 @@ func defaultFormatFunc(s *Syslog) Formatter {
349350
}
350351
}
351352
} else {
352-
file = file[len(gopath):]
353+
if strings.HasPrefix(file, gopath) {
354+
file = file[len(gopath):]
355+
}
353356
}
354357

355358
b = append(b, e.Timestamp.Format(tsFormat)...)

0 commit comments

Comments
 (0)