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

fix: decoder integer divide by zero on invalid basetype #239

Merged

Conversation

muktihari
Copy link
Owner

When receiving bad encoded FIT file such as this bytes stream []byte("\x0e\x10^\x06\x17\b\x00\x00.FIT\xe3\xbb@0000\x060000000000000000000"), It has fieldDef with invalid BaseType causing our decoder to panic when doing this operation fieldDef.Size%fieldDef.BaseType.Size() since Size will return 0. To avoid this, let's make invalid size to be 255 just like all invalid values is the max size of the types. Any value modulo by 255 is always the value itself and any value divided by 255 will always zero.

@muktihari muktihari added the bug Something isn't working label May 8, 2024
@muktihari muktihari self-assigned this May 8, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (68c4c9a) to head (86e9a12).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #239   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         3602      3602           
=========================================
  Hits          3602      3602           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muktihari muktihari merged commit 20e587c into master May 8, 2024
4 checks passed
@muktihari muktihari deleted the fix/decoder-integer-divide-by-zero-on-invalid-basetype branch May 8, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants