-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Audit source-generated marshallers for integer overflow bugs #69532
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsFor example, here: Line 69 in bcded44
What happens when this multiplication overflows?
|
Should we be wrapping most arithmetic operations in e.g., I believe this would use the |
Yes. And/or do buffer size calculations using
There is a lot of generic guidance about integer overflows. I do not know about a good .NET specific guidance. @GrabYourPitchforks ? |
Yeah I get the general problem. My first thought was that .NET always checked this by default - didn't realize this wasn't the case. The second part of this query is after reading the JIT code for |
I think it is fine to use |
This might also be able to drive some work for the JIT to handle cases where I'd agree that using |
I noticed this in the string marshallers as well the other day, e.g.: Line 48 in 6ca8c9b
I think the worst that will happen here is a runtime exception since somebody somewhere will detect the overflow, but I don't think we want to rely on the good graces of the implementation to handle error checking on our behalf. |
For example, here:
runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshalling/ArrayMarshaller.cs
Line 69 in bcded44
What happens when this multiplication overflows?
The text was updated successfully, but these errors were encountered: