dhcpv4 runtime error: slice bounds out of range
- Dominant language
- Go
- Stars
- 6.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
dhcpv4 runtime error: slice bounds out of range
The code that can course this error without panic:
```go
package main
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"encoding/hex"
"fmt"
)
func main(){
buf,err:=hex.DecodeString(`4500010ffa520000ff11bc8501020304ffffffff0044004300fbf9690101ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`)
if err!=nil{
panic(err)
}
packet:=gopacket.NewPacket(buf,layers.LayerTypeIPv4,gopacket.Default)
fmt.Println(packet.ErrorLayer().Error())
}
```
The code that can course this error with panic:
```go
package main
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"encoding/hex"
"fmt"
)
func main(){
buf,err:=hex.DecodeString(`0101ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063825363`)
if err!=nil{
panic(err)
}
obj:=&layers.DHCPv4{}
err=obj.DecodeFromBytes(buf,gopacket.NilDecodeFeedback)
fmt.Println(err)
}
```
Contributor guide
Assessment
This issue has not been assessed yet.