You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/05/14 19:27:56 UTC

[Bug 63431] New: buggy read() in ChunkedCipherInputStream

https://bz.apache.org/bugzilla/show_bug.cgi?id=63431

            Bug ID: 63431
           Summary: buggy read() in ChunkedCipherInputStream
           Product: POI
           Version: 4.0.x-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POIFS
          Assignee: dev@poi.apache.org
          Reporter: tallison@apache.org
  Target Milestone: ---

Over on TIKA-2873, we were just hit with this.

In ChunkedCipherInputStream, read() is guaranteed to return -1 if there was
something in the stream:

@Override
public int read() throws IOException {
    byte[] b = \{ 0 };
    // FIXME: compare against -1 or 1? (bug 59893)
    return (read(b) == 1) ? -1 : b[0];
}

This is related to 59893...and probably should be:

@Override
public int read() throws IOException {
    byte[] b = \{ 0 };
    // FIXME: compare against -1 or 1? (bug 59893)
    return (read(b) == -1) ? -1 : b[0];
}

I just made the change and all tests pass...any reason not to fix this?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63431] buggy read() in ChunkedCipherInputStream

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63431

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
Definitely looks like a bug to me. +1 for merging.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63431] buggy read() in ChunkedCipherInputStream

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63431

--- Comment #2 from Andreas Beeker <ki...@apache.org> ---
Although ChunkedCipherInputStream::read(byte[], int, int, boolean) returns -1,
if no more data can be fetched and so there's no result size of 0, I would
rewrite the original code:

        if (read(b) == 1) {
            return b[0];
        }
        return -1;

to:
return (read(b) == 1) ? b[0] : -1;

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63431] buggy read() in ChunkedCipherInputStream

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63431

Tim Allison <ta...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #3 from Tim Allison <ta...@apache.org> ---
r1859251

Thank you, Andi...I was wondering about that.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org