Juan Hernandez has posted comments on this change. Change subject: fixing integer out of range exception in search ......................................................................
Patch Set 3: (1 comment) http://gerrit.ovirt.org/#/c/23488/3/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java: Line 361: searchObj.setCaseSensitive(getParameters().getCaseSensitive()); Line 362: // (Integer.MAX_VALUE - 1) is used since in SyntaxChecker code we use getMaxCount() + 1 Line 363: // If a number > maxValue is given then maxValue will be used Line 364: int maxValue = Integer.MAX_VALUE - 1; Line 365: searchObj.setMaxCount(getParameters().getMaxCount() == -1 ? maxValue : Math.min(maxValue, getParameters().getMaxCount())); This can generate overflows as well. For example, if the user specifies "page 3" the resulting offset calculated in SintaxChecker will be -3: page=3 maxValue = Integer.MAX_VALUE -1 = 2147483646 maxCount = Math.min(2147483646, 2147483647) = 2147483646 offset = (page - 1) * maxCount + 1 = 2 * 2147483646 + 1 = -3 I think that when the user provides a page index we should automatically use a reasonable maxCount, not Integer.MAX_VALUE. Also to make sure that we don't overflow we should use BigInteger for these arithmetic operations in SyntaxChecker (or long, at least). Line 366: // setting FromSearch value Line 367: searchObj.setSearchFrom(getParameters().getSearchFrom()); Line 368: Line 369: if (searchObj.getError() != SyntaxError.NO_ERROR) { -- To view, visit http://gerrit.ovirt.org/23488 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I518dfdfff93dde28d9741d5e333c695239b7e7d2 Gerrit-PatchSet: 3 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> Gerrit-Reviewer: Eli Mesika <[email protected]> Gerrit-Reviewer: Juan Hernandez <[email protected]> Gerrit-Reviewer: Yair Zaslavsky <[email protected]> Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
