Review Request for JMC-6621 - Handle event size 0

Erik Gahlin erik.gahlin at oracle.com
Thu Oct 31 14:27:33 UTC 2019


Looks good. 

The JDK parser checks for a zero size, so the JMC parser should do the same,

Erik

> On 31 Oct 2019, at 15:05, Henrik Dafgård <hdafgard at gmail.com> wrote:
> 
> Hi all,
> 
> Should JMC attempt to parse a recording with an event size of 0 (this
> should not be possible) it will currently enter an infinite loop. The patch
> outlined below simply adds a check for size 0 and then throws a
> CouldNotLoadRecordingException if that is the case.
> 
> diff -r b153474a15a6
> core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> ---
> a/core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> Fri Oct 25 15:48:20 2019 +0200
> +++
> b/core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/ChunkLoaderV1.java
> Thu Oct 31 15:00:27 2019 +0100
> @@ -84,6 +84,9 @@
>  input.seek(index);
>  int size = input.readInt();
>  long type = input.readLong();
> + if (size == 0) {
> + throw new CouldNotLoadRecordingException("Found event with invalid size
> (0)");
> + }
>  if (type != CONSTANT_POOL_EVENT_TYPE && type !=
> ChunkMetadata.METADATA_EVENT_TYPE) {
>  manager.readEvent(type, input);
>  }
> 
> 
> Cheers,
> Henrik Dafgård



More information about the jmc-dev mailing list