Skip to content

Correct the used of snprintf in owinterface_add #51

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

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

vax-r
Copy link
Collaborator

@vax-r vax-r commented Nov 29, 2023

  • origin size put in snprintf in function owinterface_add was wrong
  • correct the size from ETH_ALEN to ETH_ALEN - 1

The origin size value in snprintf of owinterface_add was ETH_ALEN, which will only allow ETH_ALEN - 1 characters to write in the buffer when string size is too long.

However, since the buffer starts from inf_name + 1, which only allow ETH_ALEN - 1 characters to be written into, plus the last character must be '\0', so we should only allow ETH_ALEN - 2 character to be written into the buffer.

That's why I create the PR and fix the size value to ETH_ALEN - 1

@jserv jserv requested a review from rickywu0421 November 29, 2023 12:34
@jserv jserv changed the title Fix : correct value in snprintf of owinterface_add Correct the used of snprintf in owinterface_add Nov 30, 2023
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Read the article How to Write a Git Commit Message and rewrite your git commit messages.

The origin size value of snprintf in owinterface_add was ETH_ALEN, if
the string size is too large, it will only allow ETH_ALEN - 1 characters
to be copied into the buffer.

However, the buffer starts from location inf_name + 1 and the last
character must be '\0', which means that the buffer only has at most
ETH_ALEN - 2 characters space left.

So the size value in snprintf of owinterface_add should be ETH_ALEN - 1
@vax-r vax-r force-pushed the Fix_size_in_snprintf branch from 3b6fcd8 to e5eb949 Compare December 1, 2023 13:03
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 1, 2023

Read the article How to Write a Git Commit Message and rewrite your git commit messages.

I've made some modification to my commit message, please take a look when you have available time.
Thanks

@jserv jserv merged commit 20d4a42 into sysprog21:main Dec 1, 2023
@jserv
Copy link
Contributor

jserv commented Dec 1, 2023

Thank @vax-r for contributing!

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.

3 participants