<Sound Dev> [9] Review Request: 8135160 Endless Loop in RiffReader
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Thu Sep 24 23:38:25 UTC 2015
Hello.
Please review the fix for jdk9.
While working on some bugs in javasound, I found one issue which
can cause an endless loop for some specific audio file. The bug is
located in the com.sun.media.sound.RIFFReader.skipBytes() method, which
incorrectly assumes that Inputstrem.skip() method should return -1 at
the end of the stream. Note that the specification of the read() method
has this assumption.
The current implementation of the skip method has a loop which stops
when the necessary amount of bytes are skipped or the -1 is returned.
In the fix I change implementation of this loop:
- The check for the negative value is removed, because such checks are
not specified.
- The check for the zero is enhanced using read() method. This is
necessary, because the specification of the skip method mention that the
zero can be returned if EOF occurred or nothing was skipped for some
other reason and the user should try again.
- Note that the skip method can return more bytes than was requested
if EOF occurred(at least this part of spec is unclear???), the check for
this is also added(otherwise the avail variable can became negative).
One new test was added, it was used as initial reproducer. One existed
test was updated.
Bug: https://bugs.openjdk.java.net/browse/JDK-8135160
Webrev can be found at: http://cr.openjdk.java.net/~serb/8135160/webrev.00
ps: Note that two review requests still active in the javasound:
http://mail.openjdk.java.net/pipermail/sound-dev/2015-September/000330.html
http://mail.openjdk.java.net/pipermail/sound-dev/2015-September/000332.html
--
Best regards, Sergey.
More information about the sound-dev
mailing list