-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hi @crewjam,
thanks for making that code available.
I'm currently experimenting with using your library to parse syslog messages that are received via a HTTPS endpoint, i.e. the client is sending messages via a HTTP POST.
In my ServeHTTP function, I'm doing basically this:
scanner := bufio.NewScanner(req.Body)
for scanner.Scan() {
b := scanner.Bytes()
if len(b) > 0 {
var m *rfc5424.Message = &rfc5424.Message{}
if err = m.UnmarshalBinary(b); err != nil {
fmt.Printf("cannot parse msg: %v\n", err)
} else {
h.msgQueue <- *m
}
}
}
req.Body.Close()
But using this, the Message field gets screwed up if more than one syslog line is sent in the request body.
Looking at func (m *Message) UnmarshalBinary(inputBuffer []byte) I fear that the assignment
m.Message = r.Bytes()
is unsafe and should be replaced by
m.Message = make([]byte, len(r.Bytes()))
copy(m.Message, r.Bytes())
Best
Michael
Metadata
Metadata
Assignees
Labels
No labels