You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/03/31 20:45:15 UTC
svn commit: r760566 - in /commons/proper/compress/trunk/src:
main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
Author: sebb
Date: Tue Mar 31 18:45:14 2009
New Revision: 760566
URL: http://svn.apache.org/viewvc?rev=760566&view=rev
Log:
Reject illegal sizes
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=760566&r1=760565&r2=760566&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Tue Mar 31 18:45:14 2009
@@ -482,8 +482,13 @@
* Set this entry's file size.
*
* @param size This entry's new file size.
+ * @throws IllegalArgumentException if the size is < 0
+ * or > {@link TarConstants#MAXSIZE} (077777777777L).
*/
public void setSize(long size) {
+ if (size > MAXSIZE || size < 0){
+ throw new IllegalArgumentException("Size is out of range: "+size);
+ }
this.size = size;
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java?rev=760566&r1=760565&r2=760566&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Tue Mar 31 18:45:14 2009
@@ -95,4 +95,21 @@
}
}
}
+
+ public void testMaxFileSize(){
+ TarArchiveEntry t = new TarArchiveEntry("");
+ t.setSize(0);
+ t.setSize(1);
+ try {
+ t.setSize(-1);
+ fail("Should have generated IllegalArgumentException");
+ } catch (IllegalArgumentException expected) {
+ }
+ t.setSize(077777777777L);
+ try {
+ t.setSize(0100000000000L);
+ fail("Should have generated IllegalArgumentException");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
}