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 potential out of bounds access in #1441 #1458

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

maximumcats
Copy link
Member

Summary

The user may have given us a vector that has too many values, so we just ignore the remainder.

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • are described in the proposed changes to the AMReX documentation, if appropriate

@@ -442,7 +442,7 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst);
{
AMREX_ASSERT(value.size() > 0);
m_value.resize(info.m_max_level);
for (int i = 0; i < value.size(); ++i) {
for (int i = 0; i < m_value.size() && i < value.size(); ++i) {
Copy link
Member

Choose a reason for hiding this comment

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

An overabundance of caution? Can't be wrong, but curious what brought that on... -M

Copy link
Member Author

Choose a reason for hiding this comment

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

In Castro I accidentally gave it a vector with max_level+1 values :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Having the vector of values also gives errors if I'd set max_level=-1, meaning I don't want to use that constraint in that particular run. But max_level=0 works for that purpose as well, since it's strictly less than

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's right, usually with AMR/tagging related things you just set it to max_level = 0 when you want to turn it off.

@WeiqunZhang WeiqunZhang merged commit d036a6d into AMReX-Codes:development Oct 16, 2020
@maximumcats maximumcats deleted the tagging_oob_fix branch November 7, 2020 19:11
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.

4 participants