[ 
https://issues.apache.org/jira/browse/COMPRESS-459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539618#comment-16539618
 ] 

ASF GitHub Bot commented on COMPRESS-459:
-----------------------------------------

Github user bodewig commented on the issue:

    https://github.com/apache/commons-compress/pull/67
  
    Thanks @ctron!
    
    Don't we need to adjust `getHeaderPadCount` in `readOldBinaryEntry` as well?
    
    At first I stumbled over the `-1` in the call to `getHeaderPadCount` but I 
think it is because the method already accounts for the trailing NUL, I guess a 
comment could help :-)
    
    One more nit, you removed a since tag from one of `CpioArchiveEntry`'s 
constructors by accident.
    
    Also, but this probably is a separate issue: `CpioArchiveOutputStream` 
seems to have the same problem (even worse, as the length we write into the 
header may be wrong). It seems we should deprecate the no-arg version of 
`getHeaderPadCount` as it only works for single bye encodings.


> CPIO fails decoding multibyte name entries
> ------------------------------------------
>
>                 Key: COMPRESS-459
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-459
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.9, 1.17
>            Reporter: Jens Reimann
>            Priority: Major
>
> Having a CPIO archive in (e.g. UTF-8) mode and having a name entry with a 
> name containing multi-byte characters the decoder fails.
> The problem IMHO is the "getHeaderPadCount" method, which assumes a single 
> byte per character:
>  
> {code:java}
>     public int getHeaderPadCount(){
>         if (this.alignmentBoundary == 0) { return 0; }
>         int size = this.headerSize + 1;  // Name has terminating null
>         if (name != null) {
>             size += name.length();
>         }
>         final int remain = size % this.alignmentBoundary;
>         if (remain > 0){
>             return this.alignmentBoundary - remain;
>         }
>         return 0;
>     }
> {code}
> However this may (or may not) be true for UTF-8.
>  
> Also it wouldn't be enough to call "String#getBytes(…)" as this might already 
> transform the underlying bytes.
> The proper solution would be to provide the name size, as read from the CPIO 
> stream, and pass it to the entry.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to