-
Notifications
You must be signed in to change notification settings - Fork 23
Avoidable, potential unsafety #6
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
Comments
Apples documentation seems to specify that it returns an error code it the name is truncated, unless I'm misunderstanding you. |
These together I understand as: A 255 byte hostname may be returned successfully but is not null terminated. |
I have a mac, I'll try this with a hostname of 255. |
Literally can't make my hostname 255 bytes on mac, it truncates to 254 bytes. Tried both the UI and via running |
@jD91mZM2 Would you be able to offer any insight into whether or not this could affect Redox OS? |
Relibc, our libc implementation, does not push a trailing NUL-byte in case of length reached. Either way, one should definitely not rely on the implementation differing from the specification :) |
Redox OS also not affected by any actual issue since relibc has a limit of |
Ah, well spotted! |
This issue was addressed in 350b1bc and covered with a bunch of tests, so I'm going to close it now; thanks, everyone! |
Uh oh!
There was an error while loading. Please reload this page.
On Unix the function is potentially unsafe, depending on implementation choices made in the platform provided POSIX
gethostname
function. In particular its documentation (man
page) reads:Although
glibc
and Linux will both never return a successful non-nullterminated result, Apples documentation even directly specifies this possibility (edit: but doesn't seem to allow it in practice, see below). The configuration is, however, much more generic than those specific systems.It would be safer to append a single NULL-byte manually in any case.
The text was updated successfully, but these errors were encountered: