-
Notifications
You must be signed in to change notification settings - Fork 348
FIX: Prevent out-of-bounds write when initializing residuals in arima… #1073
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
base: main
Are you sure you want to change the base?
Conversation
…_css Adds a small safety guard when initializing residuals to avoid a potential out-of-bounds write if ncond exceeds the series length. Behavior is unchanged for valid inputs.
|
|
|
Hello @vkverma9534 Thanks for your contribution. I mean, this seems to be like a good idea, but I'll require a concrete example on which the current implementation can run out of bounds in order to see how useful it is. Can you generate a code that triggers this error? |
|
Hello @nasaul, To demonstrate the risk of the current implementation, I’ve put together a minimal example that triggers a buffer overflow. In this snippet, we allocate a small buffer but use a fill operation that exceeds its bounds. When you run this, you'll see that it doesn't just crash; it silently corrupts adjacent memory—specifically changing the value of an unrelated variable 'b'. This illustrates how easily an out-of-bounds error can lead to unpredictable behavior or data corruption in the current state. |
|
@nasaul After reviewing the CI results, it seems that clamping ncond may introduce unintended semantic changes and platform-dependent behavior. A safer approach might be to preserve the existing assumptions and add an explicit check that fails fast when they’re violated, so users are informed rather than the code continuing in an undefined state. Any suggestions otherwise? |
|
hello @vkverma9534 I don't know if it was particularly for the changes being made in this PR. I've encountered other issues in here #1074 I've already solved them just give us time so it gets merged into main and then we can test your solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for you contribution! This is a good fix, just consider if you want to give a more clear error message. If you have time it would be nice if you could a test for this behaviour.
|
Hi @nasaul, apologies for the confusion — I accidentally dismissed the previous review while pushing the latest commit. The suggested fix has now been fully applied in fa816b8, including the clearer error handling around invalid ncond. The intent and behavior of the fix remain the same, just with improved messaging as you recommended. If you have a moment, could you please re-review the updated changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry @vkverma9534 approved.
…_css
Adds a small safety guard when initializing residuals to avoid a potential out-of-bounds write if ncond exceeds the series length. Behavior is unchanged for valid inputs.