Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert 3.1.0 #2

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ require (
)

go 1.13

retract v3.1.0 // Contains incompatibility with 386 architecture.
71 changes: 48 additions & 23 deletions rfc5424/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rfc5424

import (
"fmt"
"math"
"time"

"github.com/observiq/go-syslog/v3"
Expand All @@ -14,11 +13,11 @@ var ColumnPositionTemplate = " [col %d]"

const (
// ErrPrival represents an error in the priority value (PRIVAL) inside the PRI part of the RFC5424 syslog message.
ErrPrival = "expecting a priority value in the range 1-255 or equal to 0"
ErrPrival = "expecting a priority value in the range 1-191 or equal to 0"
// ErrPri represents an error in the PRI part of the RFC5424 syslog message.
ErrPri = "expecting a priority value within angle brackets"
// ErrVersion represents an error in the VERSION part of the RFC5424 syslog message.
ErrVersion = "expecting a version value in the range 0-%d"
ErrVersion = "expecting a version value in the range 1-999"
// ErrTimestamp represents an error in the TIMESTAMP part of the RFC5424 syslog message.
ErrTimestamp = "expecting a RFC3339MICRO timestamp or a nil value"
// ErrHostname represents an error in the HOSTNAME part of the RFC5424 syslog message.
Expand Down Expand Up @@ -112,8 +111,6 @@ func (m *machine) text() []byte {
// It can also partially parse input messages returning a partially valid structured representation
// and the error that stopped the parsing.
func (m *machine) Parse(input []byte) (syslog.Message, error) {
test := math.MaxUint32

m.data = input
m.p = 0
m.pb = 0
Expand Down Expand Up @@ -1453,6 +1450,8 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto stCase654
case 655:
goto stCase655
case 656:
goto stCase656
case 657:
goto stCase657
case 658:
Expand Down Expand Up @@ -1532,7 +1531,7 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto st0
tr7:

m.err = fmt.Errorf(ErrVersion+ColumnPositionTemplate, math.MaxUint16, m.p)
m.err = fmt.Errorf(ErrVersion+ColumnPositionTemplate, m.p)
(m.p)--

{
Expand Down Expand Up @@ -1835,14 +1834,21 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto _testEof2
}
stCase2:
if (m.data)[(m.p)] == 62 {
goto st4
switch (m.data)[(m.p)] {
case 48:
goto tr3
case 49:
goto tr4
}

if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
if 50 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
goto tr5
}
goto tr2
tr3:

m.pb = m.p

goto st3
st3:
if (m.p)++; (m.p) == (m.pe) {
goto _testEof3
Expand All @@ -1861,7 +1867,7 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto _testEof4
}
stCase4:
if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
if 49 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
goto tr8
}
goto tr7
Expand Down Expand Up @@ -11047,20 +11053,37 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto _testEof655
}
stCase655:
test = common.UnsafeUTF8DecimalCodePointsToInt(m.text())
output.version = uint16(common.UnsafeUTF8DecimalCodePointsToInt(m.text()))

if test > math.MaxUint16 {
goto tr7
}
output.version = uint16(common.UnsafeUTF8DecimalCodePointsToInt(m.text()))

if (m.data)[(m.p)] == 32 {
goto st6
}
if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
goto st655
goto st656
}
goto tr7
st656:
if (m.p)++; (m.p) == (m.pe) {
goto _testEof656
}
stCase656:

output.version = uint16(common.UnsafeUTF8DecimalCodePointsToInt(m.text()))

if (m.data)[(m.p)] == 32 {
goto st6
}
goto tr7
tr4:

m.pb = m.p

goto st657
st657:
if (m.p)++; (m.p) == (m.pe) {
goto _testEof657
}
stCase657:

output.priority = uint8(common.UnsafeUTF8DecimalCodePointsToInt(m.text()))
Expand All @@ -11086,19 +11109,15 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
goto _testEof658
}
stCase658:
test = common.UnsafeUTF8DecimalCodePointsToInt(m.text())

output.priority = uint8(common.UnsafeUTF8DecimalCodePointsToInt(m.text()))
output.prioritySet = true

if test > math.MaxUint8 {
goto tr2
}

if (m.data)[(m.p)] == 62 {
goto st4
}
if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
goto st658
goto st3
}
goto tr2
st659:
Expand Down Expand Up @@ -13271,6 +13290,12 @@ func (m *machine) Parse(input []byte) (syslog.Message, error) {
_testEof655:
m.cs = 655
goto _testEof
_testEof656:
m.cs = 656
goto _testEof
_testEof657:
m.cs = 657
goto _testEof
_testEof658:
m.cs = 658
goto _testEof
Expand Down