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

validate number of aorc columns before reading. fixes #372 #373

Merged
merged 2 commits into from
Feb 10, 2022

Conversation

hellkite500
Copy link
Member

Give appropriate error message when using default forcing provider with incorrect file structure.

Changes

  • minimal validation of data in Forcing::read_forcing_aorc

Testing

  1. Added unit test to test/forcing/Forcing_test.cpp
  2. All tests passing locally

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Target Environment support

  • Linux
  • MacOs

@hellkite500 hellkite500 added the bug Something isn't working label Feb 2, 2022
@hellkite500 hellkite500 self-assigned this Feb 2, 2022
Copy link
Contributor

@donaldwj donaldwj left a comment

Choose a reason for hiding this comment

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

No problems I can see

@stcui007
Copy link
Contributor

stcui007 commented Feb 7, 2022

In Forcing.h, line 655:
if( header.size() != 10 ){
This assume number of columns is fixed at 10. Is it possible to make it more general?

@hellkite500
Copy link
Member Author

hellkite500 commented Feb 7, 2022

In Forcing.h, line 655: if( header.size() != 10 )

@stcui007
Not in this case, because this particular parser is expecting exactly this number of columns, the parsing of the vector reads exact indicies.

Ultimately, this class will likely become deprecated. I added this fix because if you aren't careful, it is possible to try to load a CSV file using this parser, and not the more generic one, in which case you get seg-faults without any useful warnings, errors, or indications as to what went wrong.

Copy link
Contributor

@stcui007 stcui007 left a comment

Choose a reason for hiding this comment

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

Good for me.

@mattw-nws mattw-nws merged commit 0d04d52 into NOAA-OWP:master Feb 10, 2022
@hellkite500 hellkite500 deleted the bugfix-372 branch March 15, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ngen segfaults and crashes when using csv file without enough columns and not using csvPerFeature provider
4 participants