Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-459

CPIO fails decoding multibyte name entries

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9, 1.17
    • 1.18
    • Archivers

    Description

      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:

       

          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;
          }
      

      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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            ctron Jens Reimann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment