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

AP_Filesystem: guarantee load_file() data is null-terminated #26310

Merged
merged 2 commits into from
May 4, 2024

Conversation

tpwrules
Copy link
Contributor

Provides the same safety guarantee and user experience improvement as AP_ROMFS::find_decompress.

Also clean up the users and the comments and clarify AP_ROMFS's usage too.

Tested on CubeOrange. Flashing its own bootloader works and so does the LASTLOG.TXT, which exercises the changed code.

@tpwrules tpwrules force-pushed the file-null-termination branch from 2c98217 to c0a88f6 Compare February 23, 2024 23:04
@tpwrules
Copy link
Contributor Author

Whoops, forgot that strtok writes to the source and can't directly take the const pointer in the FileData.

tpwrules added 2 commits May 4, 2024 07:07
Also remove the redundant insertion of the null terminator.
Improves safety of use and clarity of users. Termination is not
included in the reported size to avoid changing user behavior or
misrepresenting the file contents.
@tridge tridge force-pushed the file-null-termination branch from c0a88f6 to 1f347ef Compare May 3, 2024 21:07
@tridge tridge merged commit 0ca3738 into ArduPilot:master May 4, 2024
91 checks passed
@tpwrules tpwrules deleted the file-null-termination branch May 4, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants