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
Partitions() on macOS may return uninitialized elements #1390
Comments
I can not reproduce by using
and also |
In our project's continuous build, we saw this issue only on 10.14 (I believe that is the oldest version we tested). It did not occur on newer releases. Referring to the manpage for getfsstat() ( https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getfsstat.2.html ), it's says that "Upon successful completion, the number of statfs structures is returned." I suspect that newer macOS releases changed the implementation so the current behavior happens to work, but the code should be truncating the items to the returned count (as I did in #1392 ) so that it's not depending on undefined behavior. Thanks, |
Hmm. We don't have any reports from others, but I would like to merge at least this change seems to have no negative impact. Could you add some comments like this?
|
Describe the bug
When calling disk.Partitions() on macOS (observed only on 10.14, so far), there may be uninitialized elements returned at the end of the PartitionStat array.
This happens because we don't truncate the fs array to the number of items returned by the second call to unix.Getfsstat(). This count may be less than the count returned by the first call to getfsstat.
To Reproduce
Expected behavior
All elements in partitions contain valid data.
Environment (please complete the following information):
sw_vers
anduname -a
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G103
Darwin (hostname redacted) 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
Additional context
The text was updated successfully, but these errors were encountered: