[jira] Created: (CODEC-102) Base64OutputStream can miss last byte

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CODEC-102) Base64OutputStream can miss last byte

JIRA jira@apache.org
Base64OutputStream can miss last byte
-------------------------------------

                 Key: CODEC-102
                 URL: https://issues.apache.org/jira/browse/CODEC-102
             Project: Commons Codec
          Issue Type: Bug
    Affects Versions: 1.4
         Environment: Not important
            Reporter: Ephraim Khantsis


Base64OutputStream misuses Base64.encode class. The documentation specifically says to call call encode with inAvail = -1, in order to signal Base64 that there is no more input, and it should wrap up the remaining bytes. Base64OutputStream does not do so, and as a result, last bytes can be missed.

My proposed fix is to add the following to beginning of Base64OutputStream.flush(boolean):
if (doEncode) {
   base64.encode(null, 0, -1);
}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CODEC-102) Base64OutputStream can miss last byte

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CODEC-102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ephraim Khantsis updated CODEC-102:
-----------------------------------

     Original Estimate: 0.02h  (was: 168h)
    Remaining Estimate: 0.02h  (was: 168h)
           Environment:     (was: Not important)
           Description:
Base64OutputStream misuses Base64.encode class. The documentation specifically says to call call encode with inAvail = -1, in order to signal Base64 that there is no more input, and it should wrap up the remaining bytes. Base64OutputStream does not do so, and as a result, last bytes can be missed.

My proposed fix is to add the following to beginning of Base64OutputStream#flush(boolean):
if (doEncode) {
   base64.encode(null, 0, -1);
}

  was:
Base64OutputStream misuses Base64.encode class. The documentation specifically says to call call encode with inAvail = -1, in order to signal Base64 that there is no more input, and it should wrap up the remaining bytes. Base64OutputStream does not do so, and as a result, last bytes can be missed.

My proposed fix is to add the following to beginning of Base64OutputStream.flush(boolean):
if (doEncode) {
   base64.encode(null, 0, -1);
}


> Base64OutputStream can miss last byte
> -------------------------------------
>
>                 Key: CODEC-102
>                 URL: https://issues.apache.org/jira/browse/CODEC-102
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Ephraim Khantsis
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> Base64OutputStream misuses Base64.encode class. The documentation specifically says to call call encode with inAvail = -1, in order to signal Base64 that there is no more input, and it should wrap up the remaining bytes. Base64OutputStream does not do so, and as a result, last bytes can be missed.
> My proposed fix is to add the following to beginning of Base64OutputStream#flush(boolean):
> if (doEncode) {
>    base64.encode(null, 0, -1);
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (CODEC-102) Base64OutputStream can miss last byte

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CODEC-102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ephraim Khantsis closed CODEC-102.
----------------------------------

    Resolution: Invalid

i noticed Base64OutputStream#close calls it, so let it slip

> Base64OutputStream can miss last byte
> -------------------------------------
>
>                 Key: CODEC-102
>                 URL: https://issues.apache.org/jira/browse/CODEC-102
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Ephraim Khantsis
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> Base64OutputStream misuses Base64.encode class. The documentation specifically says to call call encode with inAvail = -1, in order to signal Base64 that there is no more input, and it should wrap up the remaining bytes. Base64OutputStream does not do so, and as a result, last bytes can be missed.
> My proposed fix is to add the following to beginning of Base64OutputStream#flush(boolean):
> if (doEncode) {
>    base64.encode(null, 0, -1);
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.