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

EvseV2G/IsoMux: check if if_name is nullptr #925

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

hikinggrass
Copy link
Contributor

This can happen if there are no interfaces with IPv6 addresses and would lead to a segfault later on

Describe your changes

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

Copy link
Contributor

@james-ctc james-ctc left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link
Contributor

@SebaLukas SebaLukas left a comment

Choose a reason for hiding this comment

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

See comments. I dont know if these checks are necessary

modules/EvseV2G/connection/connection.cpp Show resolved Hide resolved
@@ -112,6 +112,10 @@ int check_interface(struct v2g_context* v2g_ctx) {
v2g_ctx->if_name = choose_first_ipv6_interface();
}

if (v2g_ctx->if_name == nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In line 125 there is already a check if if_name == nulltpr. So the segfault is happening in line 119 (mreq.ipv6mr_interface = if_nametoindex(v2g_ctx->if_name);) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly

Copy link
Contributor

@james-ctc james-ctc left a comment

Choose a reason for hiding this comment

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

strcmp call needs to be protected

Copy link
Contributor

@james-ctc james-ctc left a comment

Choose a reason for hiding this comment

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

looks good to me

This can happen if there are no interfaces with IPv6 addresses and would lead to a segfault later on

Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
@hikinggrass hikinggrass merged commit ce3e937 into main Oct 29, 2024
10 checks passed
@hikinggrass hikinggrass deleted the bugfix/check-if_name-for-nullptr branch October 29, 2024 12:14
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.

4 participants