ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1452022 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/types/resources/comparators/Size.java
Date Sun, 03 Mar 2013 09:59:48 GMT
Author: bodewig
Date: Sun Mar  3 09:59:47 2013
New Revision: 1452022

URL: http://svn.apache.org/r1452022
Log:
size comparator was vulnerable to integer overflows.  PR 54623

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/Size.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1452022&r1=1452021&r2=1452022&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Mar  3 09:59:47 2013
@@ -77,6 +77,10 @@ Fixed bugs:
  * Base64Converter not properly handling bytes with MSB set (not masking byte to int conversion)
    Bugzilla Report 54460
 
+ * The size resource comparator would return wrong results if file
+   sizes differed by more than 2 GB.
+   Bugzilla Report 54623
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/Size.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/Size.java?rev=1452022&r1=1452021&r2=1452022&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/Size.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/Size.java Sun
Mar  3 09:59:47 2013
@@ -32,7 +32,8 @@ public class Size extends ResourceCompar
      *         argument is less than, equal to, or greater than the second.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        return (int) (foo.getSize() - bar.getSize());
+        long diff = foo.getSize() - bar.getSize();
+        return diff > 0 ? 1 : (diff == 0 ? 0 : -1);
     }
 
 }



Mime
View raw message