Skip to content

Commit cb298c5

Browse files
committed
Fix message size and empty year
1 parent 061db97 commit cb298c5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

filebeat/input/syslog/event.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ func (s *event) SetTimeZone(b []byte) {
137137

138138
// SetMonthNumeric sets the month with a number.
139139
func (s *event) SetMonthNumeric(b []byte) {
140-
s.month = monthIndexed[bytesToInt(skipLeadZero(b))]
140+
month := bytesToInt(skipLeadZero(b))
141+
if month <= 12 {
142+
s.month = monthIndexed[month]
143+
}
141144
}
142145

143146
// SetMonth sets the month.
@@ -211,6 +214,9 @@ func (s *event) Year() int {
211214

212215
// SetMessage sets the message.
213216
func (s *event) SetMessage(b []byte) {
217+
if len(b) < 3 {
218+
return
219+
}
214220
// remove BOM
215221
if b[0] == 0xef && b[1] == 0xbb && b[2] == 0xbf {
216222
s.message = string(b[3:])

filebeat/input/syslog/rfc3164_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,16 @@ func TestPriority(t *testing.T) {
796796
}
797797
}
798798

799+
func TestParserRFC3164InvalidMonthNumeric(t *testing.T) {
800+
event := newEvent()
801+
ParserRFC3164([]byte("0000-20-"), event)
802+
}
803+
804+
func TestParserRFC3164ShortMessage(t *testing.T) {
805+
event := newEvent()
806+
ParserRFC3164([]byte("Oct 1 00:00:00 \xef"), event)
807+
}
808+
799809
var e *event
800810

801811
func BenchmarkParserRFC3164r(b *testing.B) {

0 commit comments

Comments
 (0)