You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/05/02 17:01:04 UTC

[jira] [Commented] (ARTEMIS-1135) Overflows during integer addition or multiplication

    [ https://issues.apache.org/jira/browse/ARTEMIS-1135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15993276#comment-15993276 ] 

ASF subversion and git services commented on ARTEMIS-1135:
----------------------------------------------------------

Commit 33c94635bf56b4844e0b781a9340ec102f58a713 in activemq-artemis's branch refs/heads/master from [~adityasharad]
[ https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git;h=33c9463 ]

ARTEMIS-1135: Fix integer multiplication overflows

Multiplication operations where the operands have type `int` but the
result is cast to `long` may lead to overflow.
Fixes two instances of this problem, by ensuring the operands are cast
to `long` during multiplication.
This resolves the "Result of integer multiplication cast to long"
alerts at https://lgtm.com/projects/g/apache/activemq-artemis/alerts.


> Overflows during integer addition or multiplication
> ---------------------------------------------------
>
>                 Key: ARTEMIS-1135
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-1135
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Aditya Sharad
>
> The "Result of integer multiplication cast to long" and "Implicit narrowing conversion in compound assignment" rules at https://lgtm.com/projects/g/apache/activemq-artemis/alerts/ detect multiple instances of potential overflow during integer addition or multiplication. 
> The first rule detects two instances where the result of the multiplication is cast to {{long}}, but the individual operands are {{int}}s. This may lead to overflow during the multiplication.
> - In {{MySQLSQLProvider}}, this occurs when setting the max blob size, which overflows to zero at runtime rather than the intended 4GB.
> - In {{MQTTProtocolHandler}}, this occurs when determining the time to keep the connection alive.
> The second rule detects two instances where a {{long}} value is added to an {{int}}-valued variable, forcing implicit conversion and possibly overflow.
> - In {{AddressControlImpl}}, queue message counts are {{longs}} but added up in an {{int}}.
> - In {{MessageCounter.DayCounter}}, the {{counters}} array elements will have {{long}} message counts added to them, and so should be of type {{long}}.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)