Amend #3043 by allowing a longer hostname and simplifying the code.#3044
Merged
Conversation
loriab
reviewed
Sep 3, 2023
| // host name has up to HOST_NAME_MAX (64 or 256) + 1 bytes, and must end in the null byte | ||
| std::vector<char> name(257); | ||
| error = gethostname(name.data(), name.size()); | ||
| if (error) strncpy(name.data(), "nohostname", name.size()); |
Member
There was a problem hiding this comment.
I wasn't sure about 11 -> name.size() here, but https://cplusplus.com/reference/cstring/strncpy/ convinced me that it's doing the padding right.
overall, lgtm. any concerns, @zachglick ?
Contributor
There was a problem hiding this comment.
no concerns, I agree this is a better way to do things. thanks Susi!
zachglick
approved these changes
Sep 3, 2023
loriab
approved these changes
Sep 3, 2023
loriab
enabled auto-merge
September 3, 2023 16:47
loriab
pushed a commit
that referenced
this pull request
Oct 4, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improvements discussed in a comment to #3043. The 64-character limit may not be valid on all architectures; this PR should avoid having to revisit the patch.
User API & Changelog headlines
Dev notes & details
Questions
Checklist
Status