Skip to content

Commit

Permalink
[improve] Validate range of argument before long -> int conversion (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Jun 4, 2024
1 parent 9454985 commit 7529357
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,15 @@ protected CompletableFuture<PositionInPendingAckStats> internalGetPositionStatsP

protected CompletableFuture<Void> internalAbortTransaction(boolean authoritative, long mostSigBits,
long leastSigBits) {

if (mostSigBits < 0 || mostSigBits > Integer.MAX_VALUE) {
return CompletableFuture.failedFuture(new IllegalArgumentException("mostSigBits out of bounds"));
}

int partitionIdx = (int) mostSigBits;

return validateTopicOwnershipAsync(
SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.getPartition((int) mostSigBits), authoritative)
SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.getPartition(partitionIdx), authoritative)
.thenCompose(__ -> validateSuperUserAccessAsync())
.thenCompose(__ -> pulsar().getTransactionMetadataStoreService()
.endTransaction(new TxnID(mostSigBits, leastSigBits), TxnAction.ABORT_VALUE, false));
Expand Down

0 comments on commit 7529357

Please sign in to comment.