-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix memory overflow in getFiles() causing device crashes #7924
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
base: develop
Are you sure you want to change the base?
Fix memory overflow in getFiles() causing device crashes #7924
Conversation
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.
Pull Request Overview
This PR fixes a critical memory overflow issue in the getFiles() function that was causing Android app crashes due to std::bad_alloc exceptions during file manifest generation. The fix implements memory protection mechanisms and limits file enumeration to prevent device crashes.
Key changes:
- Replaces recursive vector allocation with reference passing in
getFiles() - Adds heap memory checks before file manifest generation
- Implements a 50-file limit to prevent memory exhaustion
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/FSCommon.cpp | Refactors getFiles() to use reference passing and adds safety checks for file paths and count limits |
| src/mesh/PhoneAPI.cpp | Adds heap memory validation before file manifest generation to prevent crashes |
| test_memory_fix/test/test_memory/test_main.cpp | Adds unit tests for memory protection logic and file counting limits |
| test_memory_fix/platformio.ini | Configures test environment for memory protection unit tests |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@thebentern |
|
@thebentern, please, re-run job |
- Replace recursive vector allocation with reference passing in getFiles() - Add heap memory check before file manifest generation in PhoneAPI - Limit file count to 50 to prevent memory exhaustion - Add safety checks for file paths and names - Include unit tests for memory protection logic Fixes crash when Android app connects to web server due to std::bad_alloc in getFiles() function during file manifest generation.
- Replace magic number 200 with MAX_PATH_LENGTH constant - Fix std::min type mismatch by casting to size_t
- Document memory protection mechanisms in getFilesRecursive() - Explain file count, path length, and recursion depth limits - Improve code maintainability with clear safety constraints
96434e2 to
7575db0
Compare
|
up |
73e3c77 to
e216154
Compare
getFiles()PhoneAPIFixes crash when Android app connects to web server due to
std::bad_allocingetFiles()function during file manifest generation.Serial log output
🤝 Attestations