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

Small bug fixes and cleanups from fuzz testing #3299

Merged
merged 8 commits into from
Jul 22, 2020

Conversation

greglandrum
Copy link
Member

This PR includes a number of small fixes and changes to problems that showed up during the fuzz testing:

  1. the toInt() and toDouble() functions used during the MOL file parsing now generate errors if the input strings contain characters that cannot appear in numbers. This is necessary because both strtol and atof happily return zero if they fail. Switching to boost::lexical_cast would be less code, but it is significantly slower. The changes here do not noticeably impact the speed of the code (I benchmarked mol file parsing to be sure of this)
  2. recognition of the MRV extension M MRV SMA is now stricter. We may want to consider extending this strictness to other CTAB tags.
  3. A few additional invariant checks have been added.
  4. makeAHAtomQuery() was incorrectly returning an ATOM_EQUALS_QUERY *. That query is an ATOM_NULL_QUERY, which is different.
  5. Many of the operations in StreamOps.h now explicitly throw an std::runtime_error() if they fail to read the required data from the stream.

@greglandrum greglandrum added bug Cleanup Code cleanup and refactoring Fuzz testing problems detected by fuzzing labels Jul 21, 2020
@greglandrum greglandrum added this to the 2020_09_1 milestone Jul 21, 2020
@@ -145,28 +145,56 @@ inline boost::uint32_t readPackedIntFromStream(std::stringstream &ss) {
int shift, offset;
char tmp;
ss.read(&tmp, sizeof(tmp));
if (ss.fail()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we could roll this into an ss_check inline function. We might want to check for premature eof as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but a premature EOF in the middle of reading the char here should result in the failbit being set (since the requested number of bytes wasn't read), so that case is covered. And if we hit EOF after reading the bytes we don't care (at least not here).

@bp-kelley
Copy link
Contributor

Except for the comment, all looks good.

@greglandrum greglandrum merged commit a9010da into rdkit:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Cleanup Code cleanup and refactoring Fuzz testing problems detected by fuzzing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants