jkf 2005/06/06 15:18:27 Modified: src/main/org/apache/tools/ant/taskdefs Tar.java src/main/org/apache/tools/tar TarOutputStream.java TarInputStream.java TarConstants.java . WHATSNEW Log: PR: 34241 Tar task now accepts files <8GB (was <2GB), according to POSIX tar standard. Revision Changes Path 1.55 +5 -0 ant/src/main/org/apache/tools/ant/taskdefs/Tar.java Index: Tar.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Tar.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- Tar.java 12 Nov 2004 15:14:59 -0000 1.54 +++ Tar.java 6 Jun 2005 22:18:27 -0000 1.55 @@ -371,6 +371,11 @@ TarEntry te = new TarEntry(vPath); te.setModTime(file.lastModified()); if (!file.isDirectory()) { + if (file.length() > TarConstants.MAXSIZE) + { + throw new BuildException("File: " + file + " larger than " + + TarConstants.MAXSIZE + " bytes."); + } te.setSize(file.length()); te.setMode(tarFileSet.getMode()); } else { 1.20 +3 -3 ant/src/main/org/apache/tools/tar/TarOutputStream.java Index: TarOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarOutputStream.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- TarOutputStream.java 11 Jan 2005 18:41:21 -0000 1.19 +++ TarOutputStream.java 6 Jun 2005 22:18:27 -0000 1.20 @@ -43,8 +43,8 @@ public static final int LONGFILE_GNU = 2; protected boolean debug; - protected int currSize; - protected int currBytes; + protected long currSize; + protected long currBytes; protected byte[] oneBuf; protected byte[] recordBuf; protected int assemLen; @@ -189,7 +189,7 @@ if (entry.isDirectory()) { this.currSize = 0; } else { - this.currSize = (int) entry.getSize(); + this.currSize = entry.getSize(); } } 1.20 +12 -8 ant/src/main/org/apache/tools/tar/TarInputStream.java Index: TarInputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarInputStream.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- TarInputStream.java 21 Mar 2005 10:05:42 -0000 1.19 +++ TarInputStream.java 6 Jun 2005 22:18:27 -0000 1.20 @@ -38,8 +38,8 @@ protected boolean debug; protected boolean hasHitEOF; - protected int entrySize; - protected int entryOffset; + protected long entrySize; + protected long entryOffset; protected byte[] readBuf; protected TarBuffer buffer; protected TarEntry currEntry; @@ -119,13 +119,18 @@ * is left in the entire archive, only in the current entry. * This value is determined from the entry's size header field * and the amount of data already read from the current entry. - * + * Integer.MAX_VALUE is returen in case more than Integer.MAX_VALUE + * bytes are left in the current entry in the archive. * * @return The number of available bytes for the current entry. * @throws IOException for signature */ public int available() throws IOException { - return this.entrySize - this.entryOffset; + if (this.entrySize - this.entryOffset > Integer.MAX_VALUE) + { + return Integer.MAX_VALUE; + } + return (int) (this.entrySize - this.entryOffset); } /** @@ -198,7 +203,7 @@ } if (this.currEntry != null) { - int numToSkip = this.entrySize - this.entryOffset; + long numToSkip = this.entrySize - this.entryOffset; if (this.debug) { System.err.println("TarInputStream: SKIP currENTRY '" @@ -249,8 +254,7 @@ this.entryOffset = 0; - // REVIEW How do we resolve this discrepancy?! - this.entrySize = (int) this.currEntry.getSize(); + this.entrySize = this.currEntry.getSize(); } if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) { @@ -308,7 +312,7 @@ } if ((numToRead + this.entryOffset) > this.entrySize) { - numToRead = (this.entrySize - this.entryOffset); + numToRead = (int) (this.entrySize - this.entryOffset); } if (this.readBuf != null) { 1.14 +5 -0 ant/src/main/org/apache/tools/tar/TarConstants.java Index: TarConstants.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarConstants.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- TarConstants.java 9 Mar 2004 16:48:55 -0000 1.13 +++ TarConstants.java 6 Jun 2005 22:18:27 -0000 1.14 @@ -58,6 +58,11 @@ * The length of the size field in a header buffer. */ int SIZELEN = 12; + + /** + * The maximum size of a file in a tar archive (That's 11 sevens, octal). + */ + long MAXSIZE = 077777777777L; /** * The length of the magic field in a header buffer. 1.839 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.838 retrieving revision 1.839 diff -u -r1.838 -r1.839 --- WHATSNEW 2 Jun 2005 13:58:33 -0000 1.838 +++ WHATSNEW 6 Jun 2005 22:18:27 -0000 1.839 @@ -109,6 +109,9 @@ * <xmlvalidate> and <schemavalidate> create a new parser for every file in a fileset, and so validate multiple files properly. Bugzilla Report 32791 + +* <tar> / <untar> now accepts files upto 8GB, <tar> gives an error if larger + files are to be included. This is the POSIX size limit. Other changes: --------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]