Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

border: check ifCurr before dereferencing it #1986

Merged
merged 2 commits into from
Oct 18, 2018

Conversation

sgmonroy
Copy link
Contributor

@sgmonroy sgmonroy commented Oct 16, 2018

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.


This change is Reviewable

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)


go/border/rpkt/path.go, line 137 at r1 (raw file):

// instance from the current packet.
func (rp *RtrPkt) mkInfoPathOffsets() scmp.Info {
	if curr, err := rp.IFCurr(); curr == nil || err != nil {

I think perhaps that the rest of the InfoPathOffset could still be created, with the IfID field as 0.

var ifid uint16
if curr, err := rp.IFCurr(); curr != nil && err =!= nil {
	ifid = uint16(curr)
}
...
   IfID ifid, ...

Copy link
Contributor Author

@sgmonroy sgmonroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)


go/border/rpkt/path.go, line 137 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

I think perhaps that the rest of the InfoPathOffset could still be created, with the IfID field as 0.

var ifid uint16
if curr, err := rp.IFCurr(); curr != nil && err =!= nil {
	ifid = uint16(curr)
}
...
   IfID ifid, ...

But that can be a bit misleading, you don't know if the ifCurr is pointing to a ifid with 0 value or you fail to get the current ifid

@sgmonroy sgmonroy force-pushed the br-fix-mkpathoffset branch from 7d4adc0 to 2d4edbf Compare October 16, 2018 11:51
Copy link
Contributor Author

@sgmonroy sgmonroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @kormat)


go/border/rpkt/path.go, line 137 at r1 (raw file):

Previously, sgmonroy (Sergio Gonzalez Monroy) wrote…

But that can be a bit misleading, you don't know if the ifCurr is pointing to a ifid with 0 value or you fail to get the current ifid

Done.

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

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.
@sgmonroy sgmonroy force-pushed the br-fix-mkpathoffset branch from 2d4edbf to 51397ca Compare October 18, 2018 08:32
Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@sgmonroy sgmonroy merged commit 456aab0 into scionproto:master Oct 18, 2018
@sgmonroy sgmonroy deleted the br-fix-mkpathoffset branch October 18, 2018 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants