-
Notifications
You must be signed in to change notification settings - Fork 19
Fixing a potential Integer Overflow in sendCommand() and improving styling and inline protocol explanation #3
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
Conversation
Hey @gili-yankovitch, I should be able to verify all of this on some hardware early next week, and then I will be happy to accept your PR into the repo. Thanks again and I'll keep you posted. |
Hey @gili-yankovitch , When I first tried to compile it, there were a few errors that I was able to work around by commenting/removing. Arduino couldn't find the am_util_debug.h file. What was your reasoning behind using this for debug? Is Also, Arduino didn't want to compile other things, and I wasn't sure what you were doing here:
...
...
...
If I changed these back to the previous names (i.e. write, available, read, write) then it compiled and worked. Let me know and thanks again! |
Hi, |
Hi @lewispg228, |
@gili-yankovitch Thanks a ton! We really appreciate your contribution and will look forward to anything else you might add. Regards, Owen |
@gili-yankovitch Thanks again for your work on this! I'm hoping to try this out on some hardware later this week. Also, I spoke with our engineering group about this pull request, and we discussed the use of "GOTO" in our libraries. We have never used these in any of our code previously, so we'd like to stay consistent. The preferred code for SparkFun libraries is to use "return true" or "return false" when exiting out of a function. If you're up for it, please change these "GOTO"s on your PR, but if not, I'd be happy to accept your PR and then switch them back as a separate commit. Let us know and thanks again! PS I'll report back once a get a chance to try this out on some hardware (hoping later this week). |
Hi, |
Done, though I didn't have time to test it yet. I think it should work as it involved merely replacing the 'goto's to 'return false's and 'return true' at the end of functions. Hope that helps. |
Thanks @gili-yankovitch ! I just verified this on some hardware. Every thing seems to compile fine. I will merge this in shortly. Wahoo! We really do appreciate you tweaking those gotos back to our standard style of returns. It really helps keep our libraries and examples consistent. I have not yet tried out the SHA256 feature, but I'm looking forward to using that in a future project with longer chunks of data to sign. Most of my project ideas involve embedded systems with not much data, so I'm not sure when I'll need to sign more than 32 bytes. But who knows, it will be handy to be able to create hashes and sign those! Thanks again and if you're willing, I'd love to hear about what project (or projects) you are using this hardware/library for. While testing out your PR, I just added an extra layer of security to my garage door opener. Cheers! |
Hey @gili-yankovitch , I also wrote a small example for trying it out. I hope this helps others with their first time playing around with hashes. If you have a sec, I'd appreciate you taking a look at my fix for the slight bug, and maybe even trying out example 7 on your hardware. I also added some attribution in the header on the library and example files. I hope this is okay with you. Let me know and thanks again! |
Seems legit :-) Good example and thanks for the attribution!! :D |
There was a potential integer overflow @ sendCommand() where length could be larger than the protocol overhead, mainly causing erroneous CRC calculation but might cause other types of errors such as a buffer overflow over the packet_to_CRC buffer.
Additionally, refactored the source code to pass variables to the top of functions, correct function exits, self-explanatory protocol while eliminating magic-numbers in the code (mostly around the main protocol).