From bdc6dd12650801181e76f4c4185ab096f92f09e0 Mon Sep 17 00:00:00 2001 From: Angel Soto Date: Wed, 20 Sep 2023 12:48:41 +0200 Subject: [PATCH] Check null value in newAccount method --- .../src/main/java/org/ethereum/rpc/Web3Impl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rskj-core/src/main/java/org/ethereum/rpc/Web3Impl.java b/rskj-core/src/main/java/org/ethereum/rpc/Web3Impl.java index 452daa5085e..7d415bfd9cc 100644 --- a/rskj-core/src/main/java/org/ethereum/rpc/Web3Impl.java +++ b/rskj-core/src/main/java/org/ethereum/rpc/Web3Impl.java @@ -60,6 +60,7 @@ import org.ethereum.rpc.dto.CompilationResultDTO; import org.ethereum.rpc.dto.TransactionReceiptDTO; import org.ethereum.rpc.dto.TransactionResultDTO; +import org.ethereum.rpc.exception.RskJsonRpcRequestException; import org.ethereum.rpc.parameters.*; import org.ethereum.util.BuildInfo; import org.ethereum.vm.DataWord; @@ -419,7 +420,7 @@ private String eth_getCode(HexAddressParam address, Map inputs) @Override public String eth_getBalance(HexAddressParam address, BlockRefParam blockRefParam) { - if(blockRefParam.getIdentifier() != null) { + if (blockRefParam.getIdentifier() != null) { return this.eth_getBalance(address, blockRefParam.getIdentifier()); } else { return this.eth_getBalance(address, blockRefParam.getInputs()); @@ -462,7 +463,7 @@ public String eth_getBalance(HexAddressParam address) { @Override public String eth_getStorageAt(HexAddressParam address, HexNumberParam storageIdx, BlockRefParam blockRefParam) { - if(blockRefParam.getIdentifier() != null) { + if (blockRefParam.getIdentifier() != null) { return this.eth_getStorageAt(address, storageIdx, blockRefParam.getIdentifier()); } else { return this.eth_getStorageAt(address, storageIdx, blockRefParam.getInputs()); @@ -501,7 +502,7 @@ private String eth_getStorageAt(HexAddressParam address, HexNumberParam storageI @Override public String eth_getTransactionCount(HexAddressParam address, BlockRefParam blockRefParam) { - if(blockRefParam.getIdentifier() != null) { + if (blockRefParam.getIdentifier() != null) { return this.eth_getTransactionCount(address, blockRefParam.getIdentifier()); } else { return this.eth_getTransactionCount(address, blockRefParam.getInputs()); @@ -1079,11 +1080,17 @@ public void db_getHex() { @Override public String personal_newAccountWithSeed(String seed) { + if (seed == null) { + throw RskJsonRpcRequestException.invalidParamError("Seed is null"); + } return personalModule.newAccountWithSeed(seed); } @Override public String personal_newAccount(String passphrase) { + if (passphrase == null) { + throw RskJsonRpcRequestException.invalidParamError("Passphrase is null"); + } return personalModule.newAccount(passphrase); }