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

Initialise padding after the file buffer #249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wcawijngaards
Copy link
Member

The change initializes the padding after the file buffer. Otherwise checkers report use of uninitialised memory from those bytes. It zeroes the block size after the fread, so it does not have to wipe the entire buffer. For strings, that means the library caller would have to initialize them.

@wcawijngaards wcawijngaards self-assigned this Mar 7, 2025
@lemire
Copy link
Collaborator

lemire commented Mar 10, 2025

Alternatively, you can silence the sanitizer warnings.

@wcawijngaards
Copy link
Member Author

That is true, tools have options for that. I have not used those before. I think the zero of the padding is the best choice, it is not expensive because only padding per file read, of a couple bytes per 16Kb read, and also provides actual initialization, in a defense in depth sense a good measure. If it was expensive, it can get a configure option for maintenance mode and clean debug output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants