You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Jiri Daněk (JIRA)" <ji...@apache.org> on 2018/01/24 16:47:00 UTC

[jira] [Updated] (ARTEMIS-1634) Coverity: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) in QueueControlImpl.java

     [ https://issues.apache.org/jira/browse/ARTEMIS-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jiri Daněk updated ARTEMIS-1634:
--------------------------------
    Description: 
{noformat}
   @Override
   public CompositeData[] browse(int page, int pageSize) throws Exception {
      String filter = null;
      checkStarted();

      clearIO();
      try {
         long index = 0;
CID 1464349 (#1 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) [select issue]
         long start = (page - 1) * pageSize;
CID 1464349 (#2 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially
  overflowing expression page * pageSize with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used
  in a context that expects an expression of type long (64 bits, signed). To avoid overflow, cast either page or pageSize to
  type long rather than casting the result of the potential overflow.
         long end = Math.min((long)(page * pageSize), queue.getMessageCount());
{noformat}

  was:
{noformat}
968   @Override
 969   public CompositeData[] browse(int page, int pageSize) throws Exception {
 970      String filter = null;
 971      checkStarted();
 972
 973      clearIO();
 974      try {
 975         long index = 0;
    CID 1464349 (#1 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) [select issue]
 976         long start = (page - 1) * pageSize;
    CID 1464349 (#2 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression page * pageSize with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type long (64 bits, signed).
    To avoid overflow, cast either page or pageSize to type long rather than casting the result of the potential overflow.
 977         long end = Math.min((long)(page * pageSize), queue.getMessageCount());
{noformat}


> Coverity: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) in QueueControlImpl.java
> -----------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-1634
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-1634
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.5.0
>            Reporter: Jiri Daněk
>            Priority: Major
>
> {noformat}
>    @Override
>    public CompositeData[] browse(int page, int pageSize) throws Exception {
>       String filter = null;
>       checkStarted();
>       clearIO();
>       try {
>          long index = 0;
> CID 1464349 (#1 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) [select issue]
>          long start = (page - 1) * pageSize;
> CID 1464349 (#2 of 2): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially
>   overflowing expression page * pageSize with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used
>   in a context that expects an expression of type long (64 bits, signed). To avoid overflow, cast either page or pageSize to
>   type long rather than casting the result of the potential overflow.
>          long end = Math.min((long)(page * pageSize), queue.getMessageCount());
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)