- Flash overflow fix
- Attempted to concatent strings with snprintf:
- was orignally using strcat:
- strcat has no way of anding buffer overflow
- also, strcat finds where to add new string to the buffer by starting at the first index of the buffer and increasing the index until it finds a cell with a NULL character, this is inefficient
- snprintf keeps track of last non-NULL index and protects agains buffer overflow, but iin order to not cause Flash to overflow by 624 bytes, needed to change MCU/MPU GCC Compiler->Optimization->Optimization level from None (-O0) to Optimize for size (-Os), but this "optimizes out" some of the outputs in debug mode, making it difficult to use
- was orignally using strcat:
- Combined string using memcpy, before doing so I check that the lenght of the combined string will fit into the buffer, and keep track of the index of the last non-NULL value to increase efficiency
Ghani Lawal
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.