We're streaming logs via syslog from our CDN provider, and sometimes the server crashes with "out of range panic":
panic: runtime error: index out of range
goroutine 243 [running]:
gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser/rfc5424.(*Parser).parseTimestamp(0xc000704c00, 0x1, 0x0, 0x0, 0x0, 0x0)
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/internal/syslogparser/rfc5424/rfc5424.go:196 +0x39d
gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser/rfc5424.(*Parser).parseHeader(0xc000704c00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/internal/syslogparser/rfc5424/rfc5424.go:141 +0x107
gopkg.in/mcuadros/go-syslog.v2/internal/syslogparser/rfc5424.(*Parser).Parse(0xc000704c00, 0xc000b58900, 0xc000704c00)
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/internal/syslogparser/rfc5424/rfc5424.go:85 +0x71
gopkg.in/mcuadros/go-syslog%2ev2.(*Server).parser(0xc00014e580, 0xc00080e5a8, 0x7, 0x8, 0xc0002a0be0, 0x10, 0x0, 0x0)
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/server.go:254 +0x8e
gopkg.in/mcuadros/go-syslog%2ev2.(*Server).scan(0xc00014e580, 0xc0003825c0, 0xc0002a0be0, 0x10, 0x0, 0x0)
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/server.go:242 +0xd8
created by gopkg.in/mcuadros/go-syslog%2ev2.(*Server).goScanConnection
/go/pkg/mod/gopkg.in/mcuadros/go-syslog.v2@v2.2.1/server.go:227 +0x272
It could be caused by our network, not CDN, but in any case we would like to prevent crashing and gracefully error out.
I fixed the panic mentioned above with an explicit test TestParseTimestamp_Empty. Then I added a test that feeds truncated messages to the panic and prevented corresponding panics.
Please let me know if anything needs to be changed.
Hello,
We're streaming logs via syslog from our CDN provider, and sometimes the server crashes with "out of range panic":
It could be caused by our network, not CDN, but in any case we would like to prevent crashing and gracefully error out.
I fixed the panic mentioned above with an explicit test
TestParseTimestamp_Empty
. Then I added a test that feeds truncated messages to the panic and prevented corresponding panics.Please let me know if anything needs to be changed.