Skip to content

Commit

Permalink
[SUREFIRE-2056] Reproduce buffer overflow in EventChannelEncoder when…
Browse files Browse the repository at this point in the history
… the test ID is null
  • Loading branch information
yrodiere committed Apr 4, 2022
1 parent b1615a9 commit 4e0a769
Showing 1 changed file with 19 additions and 0 deletions.
Expand Up @@ -1226,6 +1226,25 @@ public void testStdErrStreamLn() throws IOException
.isEqualTo( expected );
}

@Test
public void testStdErrStreamNullTestId() throws IOException
{
Stream out = Stream.newStream();
WritableBufferedByteChannel channel = newBufferedChannel( out );
EventChannelEncoder encoder = new EventChannelEncoder( channel );

encoder.testOutput( new TestOutputReportEntry( stdErr( "" ), NORMAL_RUN, null ) );
channel.close();

String expected = ":maven-surefire-event:\u000e:std-err-stream:"
+ (char) 10 + ":normal-run:\u0000:"
+ "\u0005:UTF-8:\u0000\u0000\u0000\u0000::";

assertThat( new String( out.toByteArray(), UTF_8 ) )
.isEqualTo( expected );
}


@Test
@SuppressWarnings( "checkstyle:innerassignment" )
public void shouldCountSameNumberOfSystemProperties() throws IOException
Expand Down

0 comments on commit 4e0a769

Please sign in to comment.