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

Fixed Off-by-one error in gethostname() #1160

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

markbrown314
Copy link
Collaborator

MAX_HOSTNAME_LEN is the maximum total characters of the hostname not including the end of string character '\0'. If the hostname happens to be 64 characters long, gethostname() would return an error and shmem_runtime_util_put_hostname() would state error "gethostname failed (-1)"

Changed length to MAX_HOSTNAME_LEN+1

Issue #1159

@bcmIntc
Copy link
Collaborator

bcmIntc commented Dec 6, 2024

Should line99 be changed to add the NULL at +1? e.g. hostname[MAX_HOSTNAME_LEN] = '\0'; ==> 'hostname[MAX_HOSTNAME_LEN + 1] = '\0';
Do you think other violations of this rule should be fixed as well? I see similar in common.h::check_hostname_validation() and runtime_util.c::shmem_runtime_util_populate_node().

@markbrown314
Copy link
Collaborator Author

Good point let me look at those.

@markbrown314
Copy link
Collaborator Author

common.h::check_hostname_validation() will need to be fixed in the test-sos tree.

MAX_HOSTNAME_LEN is the maximum total characters of the hostname not
including the end of string character '\0'. If the hostname happens to
be 64 characters long, gethostname() would return an error and
shmem_runtime_util_put_hostname() would state error "gethostname failed
(-1)"

Changed length to MAX_HOSTNAME_LEN+1

Issue Sandia-OpenSHMEM#1159

Signed-off-by: Mark F. Brown <[email protected]>
Copy link
Collaborator

@bcmIntc bcmIntc 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

@markbrown314 markbrown314 merged commit 94fc0d0 into Sandia-OpenSHMEM:main Dec 9, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants