Skip to content

Commit

Permalink
Pad the written data in case the message separator would otherwise fa…
Browse files Browse the repository at this point in the history
…ll on a 4096-byte boundary
  • Loading branch information
Martin gignac authored and Mislav Novakovic committed Dec 21, 2017
1 parent d5583c1 commit c7fa29a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions netconf/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type transportBasicIO struct {
// nessisary framining messages.
func (t *transportBasicIO) Send(data []byte) error {
t.Write(data)
// Pad to make sure the msgSeparator isn't sent across a 4096-byte boundary
if (len(data)+len(msgSeperator))%4096 < 6 {
t.Write([]byte(" "))
}
t.Write([]byte(msgSeperator))
t.Write([]byte("\n"))
return nil // TODO: Implement error handling!
Expand Down

0 comments on commit c7fa29a

Please sign in to comment.