-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix memory corruption when number of filesystems > 16 #900
Fix memory corruption when number of filesystems > 16 #900
Conversation
2282d8d
to
483111b
Compare
Good catch. I just merged #898, which should fix the build errors for you. |
483111b
to
222327b
Compare
Thanks. I rebased. I'm not sure what failed on buidkite. |
collector/filesystem_freebsd.go
Outdated
return nil, err | ||
} | ||
buf := make([]unix.Statfs_t, n) | ||
n, err = unix.Getfsstat(buf, noWait) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build failure says this should be _, err = ...
.
collector/filesystem_freebsd.go:49:2: this value of n is never used (SA4006)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no, that's wrong. It should be buf, err = ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no, that's wrong. It should be buf, err = ...
RETURN VALUES
Upon successful completion, the number of statfs structures is returned.
Otherwise, -1 is returned and the global variable errno is set to
indicate the error.
Signed-off-by: Juergen Hoetzel <[email protected]>
222327b
to
4a63cb2
Compare
Thanks. Fixed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
Signed-off-by: Juergen Hoetzel <[email protected]>
Fixes this crash:
The doubling of the array size (in the for loop) doesn't help. The
getfsstat
has already written beyond the end of the array. The correct way is to callgetfsstat
with anil/null
parameter to get the number of entries.