-
Notifications
You must be signed in to change notification settings - Fork 74
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 compiler error when -O2 optimzation is enabled #500
Conversation
Taking a look at this PR. I'll likely be pushing one commit to it to fix the unit test failures. |
Hello @djain1992! Thanks for the PR. Can you explain to me how the buffer overflow happens? The previous code caps
With this change |
Also can you tell me your compiler used and build steps? I tried to quickly reproduce this with the GNU
|
Sorry to reply late. Thing name length can be utmost MSG_GET_NEXT_BUFFER_SIZE - msgSize. If MSG_GET_NEXT_BUFFER_SIZE - msgSize is less than OTA_CLIENT_TOKEN_MAX_THINGNAME_LEN, it will overwrite the msg buffer. |
I agree with this statement. However, it is impossible for By the time you hit this line at most the first 27 characters of the So at worst case the buffer is perfectly sized. Update: full breakdown
|
With your change, the thingname can be at most |
Closing this PR as this will introduce a bug on thingnames which are longer than 53 characters. Feel free to reopen if you have a further issue. |
Compiler error was flagged when the optimization was enabled
Description
Fix the possibility of buffer overflow causing compiler error.
Checklist:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.