Change in ovirt-engine[master]: fixing integer out of range exception in search

emesika at redhat.com emesika at redhat.com
Sun Feb 9 13:33:55 UTC 2014


Eli Mesika has submitted this change and it was merged.

Change subject: fixing integer out of range exception in search
......................................................................


fixing integer out of range exception in search

The change [1] introduced to return all rows when max=-1 generates an
integer overflow in the calculation of the indexes used for paging. For
example, in an environment with one data center running a query with
"page 2" generates the following error:

<fault><reason>Operation Failed</reason><detail>statementcallback; sql
[select * from (select * from storage pool where ( id in (select storage
pool with storage domain.id from  storage pool with storage domain  ))
order by name asc ) as t1 offset (-2147483648 -1) limit 2147483647];
error: integer out of range; nested exception is
org.postgresql.util.psqlexception: error: integer out of
range</detail></fault>

The problem is in SyntaxChecker.java, in line 954, where we do the
following:

result = StringFormat.format(pagingSyntax, (page - 1) *
syntax.getMaxCount() + 1, syntax.getMaxCount());

This multiplication results in Integer.MAX_VALUE + 1, which overflows
the integer and results in the value -2147483648.

This affect all uses of queries with paging.

[1] http://gerrit.ovirt.org/21375

Change-Id: I518dfdfff93dde28d9741d5e333c695239b7e7d2
Signed-off-by: Eli Mesika <emesika at redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
M backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
2 files changed, 10 insertions(+), 5 deletions(-)

Approvals:
  Sandro Bonazzola: Looks good to me, but someone else must approve
  Eli Mesika: Verified; Looks good to me, approved
  Juan Hernandez: Looks good to me, but someone else must approve
  Yair Zaslavsky: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/23488
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I518dfdfff93dde28d9741d5e333c695239b7e7d2
Gerrit-PatchSet: 9
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emesika at redhat.com>
Gerrit-Reviewer: Eli Mesika <emesika at redhat.com>
Gerrit-Reviewer: Itamar Heim <iheim at redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Sandro Bonazzola <sbonazzo at redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzaslavs at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server



More information about the Engine-commits mailing list