You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/05/02 17:00:59 UTC

[4/4] activemq-artemis git commit: ARTEMIS-1135: Fix integer multiplication overflows

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.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/33c94635
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/33c94635
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/33c94635

Branch: refs/heads/master
Commit: 33c94635bf56b4844e0b781a9340ec102f58a713
Parents: 5a17fe0
Author: Aditya Sharad <ad...@semmle.com>
Authored: Sat Apr 29 15:03:51 2017 +0100
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue May 2 13:00:46 2017 -0400

----------------------------------------------------------------------
 .../artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java         | 2 +-
 .../activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33c94635/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
index 744ccef..26f10c6 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
@@ -21,7 +21,7 @@ import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
 
 public class MySQLSQLProvider extends GenericSQLProvider {
 
-   private static final long MAX_BLOB_SIZE = 4 * 1024 * 1024 * 1024; // 4GB
+   private static final long MAX_BLOB_SIZE = 4L * 1024 * 1024 * 1024; // 4GB
 
    private final String createFileTableSQL;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33c94635/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java
index b084f9d..4a5d12f 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolHandler.java
@@ -165,7 +165,7 @@ public class MQTTProtocolHandler extends ChannelInboundHandlerAdapter {
     */
    void handleConnect(MqttConnectMessage connect, ChannelHandlerContext ctx) throws Exception {
       this.ctx = ctx;
-      connectionEntry.ttl = connect.variableHeader().keepAliveTimeSeconds() * 1500;
+      connectionEntry.ttl = connect.variableHeader().keepAliveTimeSeconds() * 1500L;
 
       String clientId = connect.payload().clientIdentifier();
       session.getConnectionManager().connect(clientId, connect.payload().userName(), connect.payload().password(), connect.variableHeader().isWillFlag(), connect.payload().willMessage(), connect.payload().willTopic(), connect.variableHeader().isWillRetain(), connect.variableHeader().willQos(), connect.variableHeader().isCleanSession());