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

fix: fix if_nametoindex implicit declaration #267

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

aloisklink
Copy link
Contributor

The #include <net/if.h> where if_nametoindex was defined was not included.

This meant that C implicitly defined the function as int if_nametoindex(int);, when the function is actually int if_nametoindex(char *);

This doesn't cause any issues in Linux 32-bit, since there the implicit int and actual pointer parameter are the same size.

However, on Linux 64-bit, this means that the compiler sees us passing a 64-bit pointer to a 32-bit int, so who knows what will happen.

The `#include <net/if.h>` where if_nametoindex was defined was not
included.

This doesn't cause any issues in Linux 32-bit, since there the implicit
`int` and actual pointer parameter are the same size.

However, on Linux 64-bit, this means that the compiler sees us passing
a 64-bit pointer to a 32-bit int, so who knows what will happen.
@aloisklink aloisklink added the bug Something isn't working label Sep 9, 2022
Copy link
Contributor

@mereacre mereacre left a comment

Choose a reason for hiding this comment

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

Good catch.

@aloisklink aloisklink merged commit b7d45a8 into main Sep 9, 2022
@aloisklink aloisklink deleted the fix/fix-implicit-decleration-of-if_nametoindex branch September 9, 2022 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants