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

Fix bug where long directory names might not be null-terminated #206

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

Conversation

Danacus
Copy link

@Danacus Danacus commented Oct 3, 2023

On some versions of gcc, compiling mkfs.c fails because of the stringop-truncation warning triggered by this line: https://github.com/mit-pdos/xv6-riscv/blob/riscv/mkfs/mkfs.c#L154.

See gcc docs for an explanation of this warning. In short, if shortname is too long, the string in the direntry buffer will not be null-terminated.

We fixed this by copying only the first DIRSIZE - 1 bytes and setting the last byte to null.
A similar case was found in kernel/fs.c where we can instead use safestrcpy.

Please let me know if there is anything that we have overlooked.

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.

None yet

1 participant