google / google/gopacket

The SIP parser does not fail on partial SIP messages

Open
#744 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

If you attempt to parse a truncated or partial SIP message, the parser does not throw any type of error when used as:
```
parser := gopacket.NewDecodingLayerParser( layers.LayerTypeSIP, sip, )
```
I believe there should a call to SetTruncated() in the SIP parser where:
```
// Read next line
line, err = buffer.ReadBytes(byte('\n'))
if err != nil {
if err == io.EOF {
break
} else {
return err
}
}
```
should actually be:
```
// Read next line
line, err = buffer.ReadBytes(byte('\n'))
if err != nil {
if err == io.EOF {
if len(bytes.Trim(line, "\r\n")) > 0 {
df.SetTruncated()
}
break
} else {
return err
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.