-
Notifications
You must be signed in to change notification settings - Fork 696
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
Fix crash on ListPathRequest with malformed prefix #2682
Conversation
Added tests to cover the cases I found + other inputs that can make it to this method through gRPC (arbitrary text). Also fixed an error in my first approach 🚀 |
Just as a note, same as my other PR, tests are passing when I run them locally, so unless there's a style change request this should be good to merge. Thanks! |
return NewIPAddrPrefix(0, "") | ||
} | ||
return NewIPv6AddrPrefix(0, "") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going for a conservative approach as the current version was doing prefix = NewIPAddrPrefix(0, "")
on certain code paths (but maybe for different reasons). Can't remember whether I tried throwing an error on this one though.
I'll try an approach that throws an error instead when an invalid CIDR and I'll post updates here 👌
Ok now it passes all the tests, yet it is crashing again when a malformed prefix is passed because of a nil pointer somewhere else:
I'll dig deeper and propose an approach to handle this malformed input gracefully |
Unit test failed? If so, needs to fix the unit test to handle an error properly. |
When ListPathRequest is done by a gRPC client including a malformed prefix, the server would crash an invalid memory address reference. This commit fixes the crash by checking whether the parseCIDR method returned an error.
Now I implemented error handling on Table.Select() and add an additional unit test resembling the crash I posted in the last comment. CI passes now, although we have the random race fail in ci/unit, but after retrying, it should be good 🤟. Also, I did end-to-end testing by passing malformed prefixes via gRPC and gobgpd no longer crashes |
Thanks! |
When ListPathRequest is done by a gRPC client including a malformed prefix,
the server would crash with an invalid memory address reference.
This commit fixes the crash by checking whether the parseCIDR method returned an error.