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 SDL crash on validation of numeric schemas with type overflow #3750

Conversation

AKalinich-Luxoft
Copy link
Contributor

@AKalinich-Luxoft AKalinich-Luxoft commented Aug 2, 2021

Fixes #3226

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

Reproduction Steps
  1. SDL and HMI are started
  2. Navi_App is registered and activated
  3. OnTouchEventOnlyGroup is allowed by policies
  4. HMI sends OnTouchEvent notification with the 'ts' param has a value greater than maxvalue (not valid)
Expected Behavior

No Crash should be observed while testing

Observed Behavior

SDL crashed while testing

Summary

SDL crashes when the HMI sends UI.OnTouchEvent with the 'ts' param has a value greater than maxvalue.
Was added processing for the case where the SDL gets numbers that go beyond the type limit.

CLA

@AKalinich-Luxoft
Copy link
Contributor Author

@theresalech This PR is ready for Livio review

@theresalech
Copy link
Contributor

@AKalinich-Luxoft , thank you! We will include this in the upcoming release if time allows.

NumberType value(0);
if (typeid(int32_t) == typeid(value)) {
value = utils::SafeStaticCast<int64_t, int32_t>(Object.asInt());
if (Object.asInt() > std::numeric_limits<int32_t>::max() ||
Object.asInt() < std::numeric_limits<int32_t>::min()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue with this approach, some integer parameters don't have a maxvalue param, so those should be able to handle whatever value is sent (barring it being larger that 64 bits, since that is a hard limit).
Something like cancelID is currently stored in a 32 bit integer, but has no limitations as far as range. This change would make it so any value larger than 32 bits would be rejected.

To solve this, I think that we should use 64 bits for parameters which are missing either maxValue or minValue. This would need to be done in the RPC spec parser script. That, combined with this fix, should cover all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler generator script has been updated in 2852ac4 and 9891d93
Now generator has rules for int/uint 32/64 by analyzing minValue and maxValue and providing the best fit for each integer in the schema.
Note that schema item itself has been updated to properly reflect all changes from generator.

@theresalech
Copy link
Contributor

Hi @AKalinich-Luxoft , can you please review and respond to Jacob's comment? We are looking to complete development for the Core 8.0 release soon, so will need to make progress on this PR quickly in order to ensure its inclusion in the release. Thank you!

@AKalinich-Luxoft
Copy link
Contributor Author

Hi @AKalinich-Luxoft , can you please review and respond to Jacob's comment? We are looking to complete development for the Core 8.0 release soon, so will need to make progress on this PR quickly in order to ensure its inclusion in the release. Thank you!

@theresalech Luxoft is working on the fix and going to provide extra changes according to Livio comments above.

@jordynmackool
Copy link

Hi @AKalinich-Luxoft, Livio is going to begin Release candidate prep, starting on 2021-08-30. As mentioned in Theresa's comment above, we will need to make progress on this PR asap for it to be included in the upcoming release. Can you please provide timing on when Luxoft will have this PR ready for Livio review? Thanks!

@jordynmackool
Copy link

@AKalinich-Luxoft It looks like you have made new commits to this PR, is this ready for Livio review?

@AKalinich-Luxoft
Copy link
Contributor Author

@AKalinich-Luxoft It looks like you have made new commits to this PR, is this ready for Livio review?

@jordynmackool this PR will be ready for review today. We have all the required changes and just need some time to finalize the regression testing. I will let you know once it is ready for Livio review.

@AKalinich-Luxoft
Copy link
Contributor Author

@jordynmackool regression testing is finished. This PR is ready for Livio review

Copy link
Contributor

@jacobkeeler jacobkeeler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions for optimization

AKalinich-Luxoft and others added 2 commits August 24, 2021 14:13
Co-authored-by: Jacob Keeler <jacob.keeler@livioradio.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants