Skip to content

Commit 88f35f5

Browse files
committed
rfc5424: fix panic on empty msg
1 parent 32c7ba5 commit 88f35f5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

rfc5424/rfc5424.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ func parseStructuredData(buff []byte, cursor *int, l int) (string, error) {
531531
var found bool
532532

533533
if *cursor >= l {
534-
return "-", nil
535-
}
534+
return "-", nil
535+
}
536536

537537
if buff[*cursor] == NILVALUE {
538538
*cursor++

rfc5424/rfc5424_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ func (s *Rfc5424TestSuite) TestParser_Valid(c *C) {
2323
"<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts.",
2424
// with STRUCTURED-DATA
2525
`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] An application event log entry...`,
26-
2726
// STRUCTURED-DATA Only
2827
`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource= "Application" eventID="1011"][examplePriority@32473 class="high"]`,
28+
// STRUCTURED-DATA Only
29+
`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 `,
2930
}
3031

3132
tmpTs, err := time.Parse("-07:00", "-07:00")
@@ -84,6 +85,19 @@ func (s *Rfc5424TestSuite) TestParser_Valid(c *C) {
8485
"structured_data": `[exampleSDID@32473 iut="3" eventSource= "Application" eventID="1011"][examplePriority@32473 class="high"]`,
8586
"message": "",
8687
},
88+
syslogparser.LogParts{
89+
"priority": 165,
90+
"facility": 20,
91+
"severity": 5,
92+
"version": 1,
93+
"timestamp": time.Date(2003, time.October, 11, 22, 14, 15, 3*10e5, time.UTC),
94+
"hostname": "mymachine.example.com",
95+
"app_name": "evntslog",
96+
"proc_id": "-",
97+
"msg_id": "ID47",
98+
"structured_data": "-",
99+
"message": "",
100+
},
87101
}
88102

89103
c.Assert(len(fixtures), Equals, len(expected))

0 commit comments

Comments
 (0)