RFR: JDK-8294702 - BufferedInputStream uses undefined value range for markpos
Alan Bateman
alanb at openjdk.org
Tue Oct 4 15:55:18 UTC 2022
On Tue, 4 Oct 2022 15:44:48 GMT, Markus KARG <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/io/BufferedInputStream.java line 546:
>>
>>> 544: private void implReset() throws IOException {
>>> 545: getBufIfOpen(); // Cause exception if closed
>>> 546: if (markpos == -1)
>>
>> Just looking at this one again and it might be better to not change implReset. If a broken subclass were to set markpos to less than -1 then the reset() method would throw and avoid a more confusing IIOOBE or other exception.
>
> This is true, but if a broken subclass sets markpos to less than -1 then lots of code lines will work incorrectly -- including `transferTo` which was the starting point of your change proposal. So do you really only want undo the change *here*, or is it better drop this PR and even use `< 0` in `transferTo`, as I originally proposed?
> This is true, but if a broken subclass sets markpos to less than -1 then lots of code lines will work incorrectly -- including `transferTo` which was the starting point of your change proposal. So do you really only want undo the change _here_, or is it better drop this PR and even use `< 0` in `transferTo`, as I originally proposed?
This looks to be the only that would corrupt the current position (pos).
-------------
PR: https://git.openjdk.org/jdk/pull/10528
More information about the core-libs-dev
mailing list