From 02e3d817dedd71afafaae2c47db6a0849318a1d1 Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Wed, 1 Jun 2011 19:36:34 +0000 Subject: [PATCH] Merged V3.4-BUG-FIX to HEAD 28143: ALF-8602: Prevent integer overflow in batch size calculation of PatchDAOImpl.getChildAssocsForCrcFix() git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28151 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/domain/patch/ibatis/PatchDAOImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java index 9139e58359..1203420323 100644 --- a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java @@ -424,11 +424,17 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl // requery using the previous maxAssocId minAssocId = maxAssocId; // Double the range multiplier if we have a low hit-rate (<50% of desired size) - if (rows.size() < queryMaxResults / 2) + // and we can avoid integer overflow + if (rows.size() < queryMaxResults / 2 ) { - rangeMultiplier *= 2L; + long newRangeMultiplier = rangeMultiplier * 2L; + long newIdRange = maxResults * newRangeMultiplier; + if (newIdRange > 0 && newIdRange < maxIdRange) + { + rangeMultiplier = newRangeMultiplier; } } + } catch (Throwable e) { // Hit a DB problem. Log all the details of the query so that parameters can be adjusted externally.