Skip to content

Commit

Permalink
fix pax header reading.
Browse files Browse the repository at this point in the history
pax is declared to be utf-8, and the string length is in bytes.
So it must be read byte wise, not character wise. Counting characters
instead bytes confuses the byte counter on multibyte characters.
  • Loading branch information
saces committed Jul 25, 2010
1 parent 32ec7f4 commit a47b113
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

package org.apache.commons.compress.archivers.tar;

import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -231,7 +230,7 @@ public TarArchiveEntry getNextTarEntry() throws IOException {
}

private void paxHeaders() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(this, "UTF-8"));
BufferedInputStream br = new BufferedInputStream(this);
Map headers = new HashMap();
// Format is "length keyword=value\n";
while(true){ // get length
Expand All @@ -248,7 +247,7 @@ private void paxHeaders() throws IOException{
if (ch == '='){ // end of keyword
String keyword = sb.toString();
// Get rest of entry
char[] cbuf = new char[len-read];
byte[] cbuf = new byte[len-read];
int got = br.read(cbuf);
if (got != len-read){
throw new IOException("Failed to read Paxheader. Expected "+(len-read)+" chars, read "+got);
Expand Down

0 comments on commit a47b113

Please sign in to comment.