You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the IonParser::getNumberType() method, there is an invocation of the IonReader.getIntegerSize() method which could return a null value in some cases with invalid data. If the result is null, the code will throw a NullPointerException in the next line when the value is used for the switch condition.
Also, IonReader.getIntegerSize() method will throw NullPointerException in some cases, thus it is also necessary to wrap around the method invocation to ensure NullPointerException is caught.
publicNumberTypegetNumberType() throwsIOException
{
IonTypetype = _reader.getType();
if (type != null) {
// Hmmh. Looks like Ion gives little bit looser definition here;// harder to pin down exact type. But let's try some checks still.switch (type) {
caseDECIMAL:
//Ion decimals can be arbitrary precision, need to read as big decimalreturnNumberType.BIG_DECIMAL;
caseINT:
IntegerSizesize = _reader.getIntegerSize();
switch (size) {
...
The suggested fix is to add a null checking after the invocation of the IonReader.getIntegerSize() method and throw an exception if the return value stored in size is indeed null. Also, wrap the IonReader.getIntegerSize() method invocation with a try catch block to catch the possible NullPointerException.
It will return null when the reader is not positioned on an integer value, so that needs to be handled as described above.
cowtowncoder
changed the title
Unexpected NullPointerException thrown from IonParser::getNumberType()
Unexpected NullPointerException thrown from IonParser::getNumberType()Dec 30, 2023
In the
IonParser::getNumberType() method
, there is an invocation of theIonReader.getIntegerSize()
method which could return anull
value in some cases with invalid data. If the result is null, the code will throw a NullPointerException in the next line when the value is used for the switch condition.Also,
IonReader.getIntegerSize()
method will throwNullPointerException
in some cases, thus it is also necessary to wrap around the method invocation to ensureNullPointerException
is caught.The suggested fix is to add a null checking after the invocation of the
IonReader.getIntegerSize()
method and throw an exception if the return value stored insize
is indeed null. Also, wrap theIonReader.getIntegerSize()
method invocation with a try catch block to catch the possibleNullPointerException
.We found this issue by OSS-Fuzz and it is reported in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65268 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65274.
The text was updated successfully, but these errors were encountered: