Skip to content

Commit

Permalink
border: check ifCurr before dereferencing it (#1986)
Browse files Browse the repository at this point in the history
There might be situations where ifCurr has not been set or cannot be
calculated because, ie. malformed headers.

Currently the border router panics in those situations when trying to
create SCMP path offsets information.

Safe check that ifCurr is set before use.
  • Loading branch information
sgmonroy authored Oct 18, 2018
1 parent c708a27 commit 456aab0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/border/rpkt/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ func (rp *RtrPkt) validateLocalIF(ifid *common.IFIDType) error {
// mkInfoPathOffsets is a helper function to create an scmp.InfoPathOffsets
// instance from the current packet.
func (rp *RtrPkt) mkInfoPathOffsets() scmp.Info {
var ifid uint16
if curr, err := rp.IFCurr(); curr != nil && err == nil {
ifid = uint16(*curr)
}
return &scmp.InfoPathOffsets{
InfoF: uint16(rp.CmnHdr.CurrInfoF), HopF: uint16(rp.CmnHdr.CurrHopF),
IfID: uint16(*rp.ifCurr), Ingress: rp.DirFrom == rcmn.DirExternal,
IfID: ifid, Ingress: rp.DirFrom == rcmn.DirExternal,
}
}

Expand Down

0 comments on commit 456aab0

Please sign in to comment.