From 33c94635bf56b4844e0b781a9340ec102f58a713 Mon Sep 17 00:00:00 2001 From: Aditya Sharad Date: Sat, 29 Apr 2017 15:03:51 +0100 Subject: [PATCH] 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. --- .../artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java | 2 +- .../artemis/core/protocol/mqtt/MQTTProtocolHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 744ccef4e4..26f10c6bab 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; 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 b084f9d067..4a5d12f9e1 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());