Skip to content

Commit

Permalink
jackson-dataformats-binary: Catch expected IonException (#11388)
Browse files Browse the repository at this point in the history
This PR catches an expected IonException from Ion-related parsers and
also fixes some formating of fuzzers. This fixes
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65180 and
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65181.

Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan authored Dec 20, 2023
1 parent 570355c commit a781520
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions projects/jackson-dataformats-binary/IonGeneratorFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////
import com.amazon.ion.IonException;
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.io.SerializedString;
Expand Down Expand Up @@ -138,6 +139,7 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
} catch (IOException
| IllegalArgumentException
| IllegalStateException
| IonException
| UnsupportedOperationException e) {
// Known exception
}
Expand Down
3 changes: 2 additions & 1 deletion projects/jackson-dataformats-binary/IonParserFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////
import com.amazon.ion.IonException;
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.dataformat.ion.IonFactory;
Expand Down Expand Up @@ -121,7 +122,7 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
}

parser.close();
} catch (IOException | IllegalArgumentException | IllegalStateException e) {
} catch (IOException | IllegalArgumentException | IllegalStateException | IonException e) {
// Known exception
}
}
Expand Down
6 changes: 5 additions & 1 deletion projects/jackson-dataformats-binary/SerializerFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////
import com.amazon.ion.IonException;
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRawValue;
Expand Down Expand Up @@ -253,7 +254,10 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {

writer.writeValueAsString(object);
writer.writeValueAsBytes(object);
} catch (IOException | IllegalArgumentException | UnsupportedOperationException e) {
} catch (IOException
| IllegalArgumentException
| UnsupportedOperationException
| IonException e) {
// Known exception
} finally {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
}

// Create and configure SmileGenerator
SmileGenerator generator = ((SmileMapper)mapper).getFactory().createGenerator(new ByteArrayOutputStream());
SmileGenerator generator =
((SmileMapper) mapper).getFactory().createGenerator(new ByteArrayOutputStream());
for (SmileGenerator.Feature feature : featureSet) {
generator.configure(feature, data.consumeBoolean());
}
Expand Down

0 comments on commit a781520

Please sign in to comment.