Skip to content

IonReader classes contain assert statement which could throw unexpected AssertionError #417

Description

@arthurscchan

In the IonParser::getText() method, there is a call to the IonReader::stringValue() which is served by an Amazon implementation of IonReaderTextSystemX. The method does throw UnknownSymbolException if the symbol id cannot be resolved. But it also contains some assert statements which throw AssertionError when the resolved symbol id is 0 or negative. The AssertionError`` is not handled and is thrown to the users unexpectedly.

    @Override
    public String getText() throws IOException
    {
         if (_currToken != null) { // null only before/after document
          ......
            case VALUE_STRING:
                try {
                    // stringValue() will throw an UnknownSymbolException if we're
                    // trying to get the text for a symbol id that cannot be resolved.
                    return _reader.stringValue();
                } catch (UnknownSymbolException e) {
                    throw _constructError(e.getMessage(), e);
                }
            ......           
        return null;
    }

The simplest fix is to also catch the AssertionError, the same as the UnkonwnSymbolException. In general, AssertionError should be internal use only and should be wrapped and avoided by throwing directly to the users. Not sure if it is meant to not handle it in this situation.

We found this issue by OSS-Fuzz and it is reported in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64721.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fuzzIssue found by OssFuzzion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions