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

[Draft] Limit length of System.Runtime.BigInteger to int.MaxValue-32 bits #84901

Closed
wants to merge 2 commits into from

Conversation

speshuric
Copy link
Contributor

See discussion in #84670

  • Limit BigInteger.MaxLength to int.MaxValue/32 uints. This is equal to limit length in bits to int.MaxValue-32 bits
  • Fix ctor BigInteger(ReadOnlySpan<byte>, bool, bool) to check MaxLength limit
  • Fix private ctor BigInteger(ReadOnlySpan<uint>, bool) to check MaxLength limit after trying to conserve space, not before
  • Fix private ctor BigInteger(Span<uint>) to check MaxLength limit after trying to conserve space, not before
  • Fix obsolete comment in AssertValid()
  • Fix test LargeNegativeBigIntegerShiftTest to respect new limit.

fix #84670

- Limit `BigInteger.MaxLength` to `int.MaxValue/32` uints. This is equal
to limit length in bits to `int.MaxValue-32 bits`
- Fix ctor `BigInteger(ReadOnlySpan<byte>, bool, bool)` to check MaxLength
limit
- Fix private ctor `BigInteger(ReadOnlySpan<uint>, bool)` to check
`MaxLength` limit after trying to conserve space, not before
- Fix private ctor `BigInteger(Span<uint>)` to check MaxLength limit after
trying to conserve space, not before
- Fix obsolete comment in AssertValid()
- Fix test `LargeNegativeBigIntegerShiftTest` to respect new limit.

fix dotnet#84670
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 16, 2023
@ghost
Copy link

ghost commented Apr 16, 2023

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

See discussion in #84670

  • Limit BigInteger.MaxLength to int.MaxValue/32 uints. This is equal to limit length in bits to int.MaxValue-32 bits
  • Fix ctor BigInteger(ReadOnlySpan<byte>, bool, bool) to check MaxLength limit
  • Fix private ctor BigInteger(ReadOnlySpan<uint>, bool) to check MaxLength limit after trying to conserve space, not before
  • Fix private ctor BigInteger(Span<uint>) to check MaxLength limit after trying to conserve space, not before
  • Fix obsolete comment in AssertValid()
  • Fix test LargeNegativeBigIntegerShiftTest to respect new limit.

fix #84670

Author: speshuric
Assignees: -
Labels:

area-System.Numerics, community-contribution

Milestone: -

@huoyaoyuan
Copy link
Member

The overflow guard in DebuggerDisplay can also be updated.

@speshuric
Copy link
Contributor Author

The overflow guard in DebuggerDisplay can also be updated.

Thank you for point that! I'll check it.

@tannergooding
Copy link
Member

Is this still being worked on? I'd ideally like to get this one merged prior to #84733 or #83951

nit: Keep the braces please

Co-authored-by: Tanner Gooding <tagoo@outlook.com>
@speshuric
Copy link
Contributor Author

speshuric commented May 16, 2023

Is this still being worked on? I'd ideally like to get this one merged prior to #84733 or #83951

Sorry, I have been busy a bit. I'll commit the rest of changes this week.

@adamsitnik
Copy link
Member

adamsitnik commented Jul 7, 2023

I'll commit the rest of changes this week.

Thank you for your help, there is absolutely no rush from our side.

I am going to apply "need author action" label so this PR is not listed on our internal list of PRs awaiting for review.

@adamsitnik adamsitnik added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jul 7, 2023
@ghost ghost added the no-recent-activity label Jul 21, 2023
@ghost
Copy link

ghost commented Jul 21, 2023

This pull request has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@speshuric
Copy link
Contributor Author

I still plan to complete this.

@ghost ghost removed needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity labels Aug 4, 2023
@adamsitnik adamsitnik added the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 7, 2023
@adamsitnik adamsitnik added this to the Future milestone Aug 7, 2023
@ghost ghost added the no-recent-activity label Aug 21, 2023
@ghost
Copy link

ghost commented Aug 21, 2023

This pull request has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@ghost
Copy link

ghost commented Sep 4, 2023

This pull request will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the pull request, but please note that it will be locked if it remains inactive for another 30 days.

@ghost ghost closed this Sep 4, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 4, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Numerics community-contribution Indicates that the PR has been added by a community member needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IBinaryInteger<BigInteger>.GetShortestBitLength() - int overflow is not handled
4 participants