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

Check if path exists and is nonempty before reading host files #35

Merged
merged 3 commits into from
Nov 12, 2021

Conversation

ISauve
Copy link

@ISauve ISauve commented Nov 12, 2021

When we mount the required /etc files for host detection to a container, whenever a file isn't present on the host we end up creating an empty file in that location in the container. This can break host OS detection, so we need to make sure that when we check if a file exists, we also check that it contains data.

defer f.Close()

r := bufio.NewReader(f)
_, err = r.ReadString('\n')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use r.ReadSlice('\n') here, this would not create an unused string.Builder

@brycekahle
Copy link
Member

shirou#1584

@brycekahle brycekahle added the upstreamed change has been merged upstream label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstreamed change has been merged upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants