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

chore: use safer slice splitting #6437

Merged

Conversation

AaronFeickert
Copy link
Collaborator

Description

Ensures that all slice splitting is properly checked to avoid panics.

Motivation and Context

There are a few remaining uses of slice::split_at that are used to split slices. Because this can panic on a bad index, this PR moves each use to slice::split_at_checked, which cannot panic.

How Has This Been Tested?

Existing tests pass.

What process can a PR reviewer use to test or verify this change?

Ensure that each split is still being done at the same index, and that the error handling is done properly.

@AaronFeickert
Copy link
Collaborator Author

Note that this does not include the uses already addressed by #6430.

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Jul 30, 2024
Copy link

github-actions bot commented Jul 30, 2024

Test Results (CI)

    3 files    116 suites   41m 43s ⏱️
1 301 tests 1 300 ✅ 0 💤 1 ❌
3 785 runs  3 784 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 3b4dcdd.

♻️ This comment has been updated with latest results.

Copy link

Test Results (Integration tests)

 2 files  11 suites   24m 19s ⏱️
35 tests 33 ✅ 0 💤 2 ❌
37 runs  35 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit 3b4dcdd.

Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

I looked at these and found they are not a danger at this moment as they don't take in extra outside input or they check it before hand,
But the work here is done and that stuff might change in future.

@SWvheerden SWvheerden merged commit 6949d2d into tari-project:development Jul 31, 2024
13 of 16 checks passed
@AaronFeickert
Copy link
Collaborator Author

I also didn't identify any particular problems with the existing implementation. As noted, this was to reduce risk going forward in the event of changes.

@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Jul 31, 2024
@AaronFeickert AaronFeickert deleted the more-split-at-checked branch July 31, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants